mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
VideoBackends: Scale bounding box rectangle in the pixel shader
This commit is contained in:
@ -324,40 +324,11 @@ void Renderer::UnbindTexture(const AbstractTexture* texture)
|
||||
|
||||
u16 Renderer::BBoxRead(int index)
|
||||
{
|
||||
// Here we get the min/max value of the truncated position of the upscaled framebuffer.
|
||||
// So we have to correct them to the unscaled EFB sizes.
|
||||
int value = BBox::Get(index);
|
||||
|
||||
if (index < 2)
|
||||
{
|
||||
// left/right
|
||||
value = value * EFB_WIDTH / m_target_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
// up/down
|
||||
value = value * EFB_HEIGHT / m_target_height;
|
||||
}
|
||||
if (index & 1)
|
||||
value++; // fix max values to describe the outer border
|
||||
|
||||
return value;
|
||||
return static_cast<u16>(BBox::Get(index));
|
||||
}
|
||||
|
||||
void Renderer::BBoxWrite(int index, u16 _value)
|
||||
void Renderer::BBoxWrite(int index, u16 value)
|
||||
{
|
||||
int value = _value; // u16 isn't enough to multiply by the efb width
|
||||
if (index & 1)
|
||||
value--;
|
||||
if (index < 2)
|
||||
{
|
||||
value = value * m_target_width / EFB_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = value * m_target_height / EFB_HEIGHT;
|
||||
}
|
||||
|
||||
BBox::Set(index, value);
|
||||
}
|
||||
|
||||
|
@ -837,49 +837,30 @@ void Renderer::SetScissorRect(const MathUtil::Rectangle<int>& rc)
|
||||
|
||||
u16 Renderer::BBoxRead(int index)
|
||||
{
|
||||
int swapped_index = index;
|
||||
// swap 2 and 3 for top/bottom
|
||||
if (index >= 2)
|
||||
swapped_index ^= 1; // swap 2 and 3 for top/bottom
|
||||
index ^= 1;
|
||||
|
||||
// Here we get the min/max value of the truncated position of the upscaled and swapped
|
||||
// framebuffer.
|
||||
// So we have to correct them to the unscaled EFB sizes.
|
||||
int value = BoundingBox::Get(swapped_index);
|
||||
|
||||
if (index < 2)
|
||||
{
|
||||
// left/right
|
||||
value = value * EFB_WIDTH / m_target_width;
|
||||
}
|
||||
else
|
||||
int value = BoundingBox::Get(index);
|
||||
if (index >= 2)
|
||||
{
|
||||
// up/down -- we have to swap up and down
|
||||
value = value * EFB_HEIGHT / m_target_height;
|
||||
value = EFB_HEIGHT - value - 1;
|
||||
value = EFB_HEIGHT - value;
|
||||
}
|
||||
if (index & 1)
|
||||
value++; // fix max values to describe the outer border
|
||||
|
||||
return value;
|
||||
return static_cast<u16>(value);
|
||||
}
|
||||
|
||||
void Renderer::BBoxWrite(int index, u16 _value)
|
||||
void Renderer::BBoxWrite(int index, u16 value)
|
||||
{
|
||||
int value = _value; // u16 isn't enough to multiply by the efb width
|
||||
if (index & 1)
|
||||
value--;
|
||||
if (index < 2)
|
||||
{
|
||||
value = value * m_target_width / EFB_WIDTH;
|
||||
}
|
||||
else
|
||||
s32 swapped_value = value;
|
||||
if (index >= 2)
|
||||
{
|
||||
index ^= 1; // swap 2 and 3 for top/bottom
|
||||
value = EFB_HEIGHT - value - 1;
|
||||
value = value * m_target_height / EFB_HEIGHT;
|
||||
swapped_value = EFB_HEIGHT - swapped_value;
|
||||
}
|
||||
|
||||
BoundingBox::Set(index, value);
|
||||
BoundingBox::Set(index, swapped_value);
|
||||
}
|
||||
|
||||
void Renderer::SetViewport(float x, float y, float width, float height, float near_depth,
|
||||
|
@ -131,49 +131,12 @@ void Renderer::SetPipeline(const AbstractPipeline* pipeline)
|
||||
|
||||
u16 Renderer::BBoxRead(int index)
|
||||
{
|
||||
s32 value = m_bounding_box->Get(static_cast<size_t>(index));
|
||||
|
||||
// Here we get the min/max value of the truncated position of the upscaled framebuffer.
|
||||
// So we have to correct them to the unscaled EFB sizes.
|
||||
if (index < 2)
|
||||
{
|
||||
// left/right
|
||||
value = value * EFB_WIDTH / m_target_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
// up/down
|
||||
value = value * EFB_HEIGHT / m_target_height;
|
||||
}
|
||||
|
||||
// fix max values to describe the outer border
|
||||
if (index & 1)
|
||||
value++;
|
||||
|
||||
return static_cast<u16>(value);
|
||||
return static_cast<u16>(m_bounding_box->Get(index));
|
||||
}
|
||||
|
||||
void Renderer::BBoxWrite(int index, u16 value)
|
||||
{
|
||||
s32 scaled_value = static_cast<s32>(value);
|
||||
|
||||
// fix max values to describe the outer border
|
||||
if (index & 1)
|
||||
scaled_value--;
|
||||
|
||||
// scale to internal resolution
|
||||
if (index < 2)
|
||||
{
|
||||
// left/right
|
||||
scaled_value = scaled_value * m_target_width / EFB_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
// up/down
|
||||
scaled_value = scaled_value * m_target_height / EFB_HEIGHT;
|
||||
}
|
||||
|
||||
m_bounding_box->Set(static_cast<size_t>(index), scaled_value);
|
||||
m_bounding_box->Set(index, value);
|
||||
}
|
||||
|
||||
void Renderer::BBoxFlush()
|
||||
|
Reference in New Issue
Block a user