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

[draft] / [don't merge] Add support for scale_to = original in slang … #15937

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions gfx/drivers/gl2.c
Copy link
Author

@kokoko3k kokoko3k Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope I did right to use width and height instead of gl->tex_w and gl->tex_h

Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,11 @@ static void gl2_renderchain_recompute_pass_sizes(

switch (fbo_scale->type_x)
{
case RARCH_SCALE_ORIGINAL:
fbo_rect->img_width = fbo_scale->scale_x * width;
fbo_rect->max_img_width = last_max_width * fbo_scale->scale_x;
break;

case RARCH_SCALE_INPUT:
fbo_rect->img_width = fbo_scale->scale_x * last_width;
fbo_rect->max_img_width = last_max_width * fbo_scale->scale_x;
Expand All @@ -1841,6 +1846,11 @@ static void gl2_renderchain_recompute_pass_sizes(

switch (fbo_scale->type_y)
{
case RARCH_SCALE_ORIGINAL:
fbo_rect->img_height = last_height * height;
fbo_rect->max_img_height = last_max_height * fbo_scale->scale_y;
break;

case RARCH_SCALE_INPUT:
fbo_rect->img_height = last_height * fbo_scale->scale_y;
fbo_rect->max_img_height = last_max_height * fbo_scale->scale_y;
Expand Down
11 changes: 11 additions & 0 deletions gfx/drivers_shader/shader_gl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,11 @@ gl3_filter_chain_t *gl3_filter_chain_create_from_preset(
pass_info.scale_x = pass->fbo.scale_x;
pass_info.scale_type_x = GLSLANG_FILTER_CHAIN_SCALE_VIEWPORT;
break;

case RARCH_SCALE_ORIGINAL:
pass_info.scale_x = pass->fbo.scale_x;
pass_info.scale_type_x = GLSLANG_FILTER_CHAIN_SCALE_ORIGINAL;
break;
}

switch (pass->fbo.type_y)
Expand All @@ -2659,6 +2664,12 @@ gl3_filter_chain_t *gl3_filter_chain_create_from_preset(
pass_info.scale_y = pass->fbo.scale_y;
pass_info.scale_type_y = GLSLANG_FILTER_CHAIN_SCALE_VIEWPORT;
break;

case RARCH_SCALE_ORIGINAL:
pass_info.scale_y = pass->fbo.scale_x;
pass_info.scale_type_y = GLSLANG_FILTER_CHAIN_SCALE_ORIGINAL;
break;

}
}

Expand Down
9 changes: 9 additions & 0 deletions gfx/drivers_shader/shader_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3220,6 +3220,10 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset(
pass_info.scale_x = pass->fbo.scale_x;
pass_info.scale_type_x = GLSLANG_FILTER_CHAIN_SCALE_VIEWPORT;
break;
case RARCH_SCALE_ORIGINAL:
pass_info.scale_x = pass->fbo.scale_x;
pass_info.scale_type_x = GLSLANG_FILTER_CHAIN_SCALE_ORIGINAL;
break;
}

switch (pass->fbo.type_y)
Expand All @@ -3238,6 +3242,11 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset(
pass_info.scale_y = pass->fbo.scale_y;
pass_info.scale_type_y = GLSLANG_FILTER_CHAIN_SCALE_VIEWPORT;
break;

case RARCH_SCALE_ORIGINAL:
pass_info.scale_y = pass->fbo.scale_x;
pass_info.scale_type_y = GLSLANG_FILTER_CHAIN_SCALE_ORIGINAL;
break;
}
}

Expand Down
6 changes: 6 additions & 0 deletions gfx/video_shader_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ static bool video_shader_parse_pass(config_file_t *conf,
scale->type_x = RARCH_SCALE_VIEWPORT;
else if (string_is_equal(scale_type_x, "absolute"))
scale->type_x = RARCH_SCALE_ABSOLUTE;
else if (string_is_equal(scale_type_x, "original"))
scale->type_x = RARCH_SCALE_ORIGINAL;
else
{
RARCH_ERR("[Shaders]: Invalid attribute: \"%s\".\n", scale_type_x);
Expand All @@ -654,6 +656,8 @@ static bool video_shader_parse_pass(config_file_t *conf,
scale->type_y = RARCH_SCALE_VIEWPORT;
else if (string_is_equal(scale_type_y, "absolute"))
scale->type_y = RARCH_SCALE_ABSOLUTE;
else if (string_is_equal(scale_type_x, "original"))
scale->type_y = RARCH_SCALE_ORIGINAL;
else
{
RARCH_ERR("[Shaders]: Invalid attribute: \"%s\".\n", scale_type_y);
Expand Down Expand Up @@ -1015,6 +1019,8 @@ static const char *video_shader_scale_type_to_str(enum gfx_scale_type type)
return "viewport";
case RARCH_SCALE_ABSOLUTE:
return "absolute";
case RARCH_SCALE_ORIGINAL:
return "original";
default:
break;
}
Expand Down
3 changes: 2 additions & 1 deletion gfx/video_shader_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ enum gfx_scale_type
{
RARCH_SCALE_INPUT = 0,
RARCH_SCALE_ABSOLUTE,
RARCH_SCALE_VIEWPORT
RARCH_SCALE_VIEWPORT,
RARCH_SCALE_ORIGINAL
};

enum
Expand Down