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,18 +399,29 @@ void filter::transform::transform_instance::deactivate()
|
|||
|
||||
void filter::transform::transform_instance::video_tick(float)
|
||||
{
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
|
||||
// Grab parent and target.
|
||||
obs_source_t* target = obs_filter_get_target(m_self);
|
||||
if (target) {
|
||||
// Grab width an height of the target source (child filter or source).
|
||||
width = obs_source_get_base_width(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) {
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
m_source_size.first = width;
|
||||
m_source_size.second = height;
|
||||
|
||||
// Grab parent and target.
|
||||
obs_source_t* target = obs_filter_get_target(m_self);
|
||||
if (target) {
|
||||
// Grab width an height of the target source (child filter or source).
|
||||
width = obs_source_get_base_width(target);
|
||||
height = obs_source_get_base_height(target);
|
||||
}
|
||||
if (width == 0) {
|
||||
width = 1;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace filter {
|
|||
std::shared_ptr<gs::rendertarget> m_source_rendertarget;
|
||||
std::shared_ptr<gs::texture> m_source_texture;
|
||||
bool m_source_rendered;
|
||||
std::pair<uint32_t, uint32_t> m_source_size;
|
||||
|
||||
// Mipmapping
|
||||
bool m_mipmap_enabled;
|
||||
|
|
Loading…
Reference in New Issue