filter-transform: Validate source size each tick
Rendering happens with cached Geometry that is only updated when necessary, such as when the user changes settings. This optimization was necessary to reduce CPU and GPU usage as we can simply re-use the same geomtry instead of recalculating it. However, the actual source size was never checked. That meant that when a source changed size through any means, the filter would not update the geomtry accordingly, and the result was a squished or stretched image. With this, the source size is now checked each tick. Fixes #48
This commit is contained in:
parent
cbe3555223
commit
1c072d67cb
|
@ -399,8 +399,6 @@ void filter::transform::transform_instance::deactivate()
|
||||||
|
|
||||||
void filter::transform::transform_instance::video_tick(float)
|
void filter::transform::transform_instance::video_tick(float)
|
||||||
{
|
{
|
||||||
// Update Mesh
|
|
||||||
if (m_update_mesh) {
|
|
||||||
uint32_t width = 0;
|
uint32_t width = 0;
|
||||||
uint32_t height = 0;
|
uint32_t height = 0;
|
||||||
|
|
||||||
|
@ -411,6 +409,19 @@ void filter::transform::transform_instance::video_tick(float)
|
||||||
width = obs_source_get_base_width(target);
|
width = obs_source_get_base_width(target);
|
||||||
height = obs_source_get_base_height(target);
|
height = obs_source_get_base_height(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If size mismatch, force an update.
|
||||||
|
if (width != m_source_size.first) {
|
||||||
|
m_update_mesh = true;
|
||||||
|
} else if (height != m_source_size.second) {
|
||||||
|
m_update_mesh = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Mesh
|
||||||
|
if (m_update_mesh) {
|
||||||
|
m_source_size.first = width;
|
||||||
|
m_source_size.second = height;
|
||||||
|
|
||||||
if (width == 0) {
|
if (width == 0) {
|
||||||
width = 1;
|
width = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ namespace filter {
|
||||||
std::shared_ptr<gs::rendertarget> m_source_rendertarget;
|
std::shared_ptr<gs::rendertarget> m_source_rendertarget;
|
||||||
std::shared_ptr<gs::texture> m_source_texture;
|
std::shared_ptr<gs::texture> m_source_texture;
|
||||||
bool m_source_rendered;
|
bool m_source_rendered;
|
||||||
|
std::pair<uint32_t, uint32_t> m_source_size;
|
||||||
|
|
||||||
// Mipmapping
|
// Mipmapping
|
||||||
bool m_mipmap_enabled;
|
bool m_mipmap_enabled;
|
||||||
|
|
Loading…
Reference in New Issue