Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Libretro] Fix VMU scaling for dynamic res games #1347

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions core/rend/dx11/dx11_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ void DX11Overlay::draw(u32 width, u32 height, bool vmu, bool crosshair)
const float blend_factor[4] = { 0.75f, 0.75f, 0.75f, 0.75f };
deviceContext->OMSetBlendState(blendStates.getState(true, 8, 8), blend_factor, 0xffffffff);
#else
float vmu_padding = 8.f * config::RenderResolution / 480.f;
float vmu_height = 32.f * config::RenderResolution / 480.f;
float vmu_width = 48.f * config::RenderResolution / 480.f;
float vmu_padding_x = 8.f * width / 640.f;
float vmu_padding_y = 8.f * height / 480.f;
float vmu_width = 48.f * width / 640.f;
float vmu_height = 32.f * height / 480.f;
if (config::Widescreen)
{
vmu_padding_x = vmu_padding_x / 4.f * 3.f;
vmu_width = vmu_width / 4.f * 3.f;
}
deviceContext->OMSetBlendState(blendStates.getState(true, 4, 5), nullptr, 0xffffffff);
#endif

Expand Down Expand Up @@ -91,20 +97,20 @@ void DX11Overlay::draw(u32 width, u32 height, bool vmu, bool crosshair)
{
case UPPER_LEFT:
default:
x = vmu_padding;
y = vmu_padding;
x = vmu_padding_x;
y = vmu_padding_y;
break;
case UPPER_RIGHT:
x = width - vmu_padding - w;
y = vmu_padding;
x = width - vmu_padding_x - w;
y = vmu_padding_y;
break;
case LOWER_LEFT:
x = vmu_padding;
y = height - vmu_padding - h;
x = vmu_padding_x;
y = height - vmu_padding_y - h;
break;
case LOWER_RIGHT:
x = width - vmu_padding - w;
y = height - vmu_padding - h;
x = width - vmu_padding_x - w;
y = height - vmu_padding_y - h;
break;
}
#else
Expand Down
9 changes: 4 additions & 5 deletions core/rend/gles/gldraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,10 @@ static void updateVmuTexture(int vmu_screen_number)

void DrawVmuTexture(u8 vmu_screen_number, int width, int height)
{
float vmu_padding = 8.f * config::RenderResolution / 480.f;
float x = vmu_padding;
float y = vmu_padding;
float w = (float)VMU_SCREEN_WIDTH * vmu_screen_params[vmu_screen_number].vmu_screen_size_mult * 4.f / 3.f / gl.ofbo.aspectRatio * config::RenderResolution / 480.f;
float h = (float)VMU_SCREEN_HEIGHT * vmu_screen_params[vmu_screen_number].vmu_screen_size_mult * config::RenderResolution / 480.f;
float x = 8.f * width / 640.f;
float y = 8.f * height / 480.f;
float w = (float)VMU_SCREEN_WIDTH * vmu_screen_params[vmu_screen_number].vmu_screen_size_mult * 4.f / 3.f / gl.ofbo.aspectRatio * width / 640.f;
float h = (float)VMU_SCREEN_HEIGHT * vmu_screen_params[vmu_screen_number].vmu_screen_size_mult * height / 480.f;

if (vmu_lcd_changed[vmu_screen_number * 2] || vmuTextureId[vmu_screen_number] == 0)
updateVmuTexture(vmu_screen_number);
Expand Down
28 changes: 20 additions & 8 deletions core/rend/vulkan/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,21 @@ void VulkanOverlay::Draw(vk::CommandBuffer commandBuffer, vk::Extent2D viewport,

if (vmu)
{
#ifndef LIBRETRO
f32 vmu_padding = 8.f * scaling;
f32 vmu_height = 32.f * scaling;
f32 vmu_width = 48.f * scaling;
#else
f32 vmu_padding_x = 8.f * viewport.width / 640.f;
f32 vmu_padding_y = 8.f * viewport.height / 480.f;
f32 vmu_width = 48.f * viewport.width / 640.f;
f32 vmu_height = 32.f * viewport.height / 480.f;
if (config::Widescreen)
{
vmu_padding_x = vmu_padding_x / 4.f * 3.f;
vmu_width = vmu_width / 4.f * 3.f;
}
#endif

pipeline->BindPipeline(commandBuffer);
const float *color = nullptr;
Expand Down Expand Up @@ -158,20 +170,20 @@ void VulkanOverlay::Draw(vk::CommandBuffer commandBuffer, vk::Extent2D viewport,
{
case UPPER_LEFT:
default:
x = vmu_padding;
y = vmu_padding;
x = vmu_padding_x;
y = vmu_padding_y;
break;
case UPPER_RIGHT:
x = viewport.width - vmu_padding - w;
y = vmu_padding;
x = viewport.width - vmu_padding_x - w;
y = vmu_padding_y;
break;
case LOWER_LEFT:
x = vmu_padding;
y = viewport.height - vmu_padding - h;
x = vmu_padding_x;
y = viewport.height - vmu_padding_y - h;
break;
case LOWER_RIGHT:
x = viewport.width - vmu_padding - w;
y = viewport.height - vmu_padding - h;
x = viewport.width - vmu_padding_x - w;
y = viewport.height - vmu_padding_y - h;
break;
}
#else
Expand Down