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

Add Frametime Uniforms #17155

Merged
merged 37 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
12f2484
Initial implementation of CoreAspect uniform
kokoko3k Oct 22, 2024
28292a6
float -> float_t
kokoko3k Oct 22, 2024
30f9dd4
Possibly fix wii_u building
kokoko3k Oct 23, 2024
e061445
vulkan: use float instead of float_t;
kokoko3k Oct 23, 2024
6d928c5
slangp: Advertise support of CoreAspect uniform
kokoko3k Oct 23, 2024
435a651
CoreAspect + glsl fix: use glUniform1f()
kokoko3k Oct 23, 2024
e842044
Add CoreAspectRot uniform.
kokoko3k Oct 23, 2024
85f54c6
Fixed stupid typo
kokoko3k Oct 23, 2024
b90ab11
Just use _HAS_COREASPECT_UNIFORMS to check for CoreAspect uniforms su…
kokoko3k Oct 23, 2024
dc6e138
Rename CoreAspect, CoreAspectRot, _HAS_COREASPECT_UNIFORMS to Origina…
kokoko3k Oct 24, 2024
ea2f000
Merge branch 'libretro:master' into CoreAspect_uniform
kokoko3k Oct 24, 2024
c57a1e1
GLCore: void Pass::build_semantic_float needs glUniform1f.
kokoko3k Oct 24, 2024
3aca6af
d3d10,11,12, wrong function called by overlook.
kokoko3k Oct 24, 2024
32f115a
Add test shader, will remove that before PR
kokoko3k Oct 24, 2024
0a1f516
Fix metal rotated aspect reporting
kokoko3k Oct 24, 2024
aa74519
Merge branch 'libretro:master' into CoreAspect_uniform
kokoko3k Oct 25, 2024
8de41af
remove test shader
kokoko3k Oct 25, 2024
97bab31
Fix C89 Build
kokoko3k Oct 25, 2024
f20b6da
Merge branch 'libretro:master' into CoreAspect_uniform
kokoko3k Oct 28, 2024
94d0526
Merge branch 'libretro:master' into CoreAspect_uniform
kokoko3k Oct 29, 2024
36e5055
Merge branch 'libretro:master' into CoreAspect_uniform
kokoko3k Oct 30, 2024
3b220eb
Use OriginalAspectRotated instead of OriginalAspectRot
kokoko3k Oct 30, 2024
7905017
Merge branch 'libretro:master' into FrameTime_Uniforms
kokoko3k Oct 30, 2024
d1360e7
Add CoreFPS and FrameTimeDelta Uniforms.
kokoko3k Oct 30, 2024
bb74353
add test shader
kokoko3k Oct 30, 2024
2bb30b9
remote test shader
kokoko3k Nov 3, 2024
494a3c8
Merge branch 'master' into FrameTime_Uniforms
kokoko3k Nov 3, 2024
4d3c286
Wrong paste.
kokoko3k Nov 3, 2024
75858a1
gx2: use float
kokoko3k Nov 3, 2024
ebaced4
wrong indentation
kokoko3k Nov 3, 2024
7bcc624
resolved merge conflict
kokoko3k Nov 3, 2024
8c992cc
fix indentation
kokoko3k Nov 3, 2024
9f2e555
Fix comment/Formatting
kokoko3k Nov 3, 2024
dda527f
Merge branch 'libretro:master' into FrameTime_Uniforms
kokoko3k Nov 5, 2024
0dd494b
Change uniform name from CoreFPS to OriginalFPS
kokoko3k Nov 5, 2024
021c5e9
Merge branch 'libretro:master' into FrameTime_Uniforms
kokoko3k Nov 8, 2024
d096359
underliyng references: core_fps -> original_fps
kokoko3k Nov 8, 2024
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
2 changes: 2 additions & 0 deletions gfx/common/d3d10_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ typedef struct
pass_semantics_t semantics;
uint32_t frame_count;
int32_t frame_direction;
uint32_t frame_time_delta;
float original_fps;
uint32_t rotation;
uint32_t total_subframes;
uint32_t current_subframe;
Expand Down
2 changes: 2 additions & 0 deletions gfx/common/d3d11_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ typedef struct
pass_semantics_t semantics;
uint32_t frame_count;
int32_t frame_direction;
uint32_t frame_time_delta;
float original_fps;
uint32_t rotation;
uint32_t total_subframes;
uint32_t current_subframe;
Expand Down
2 changes: 2 additions & 0 deletions gfx/common/d3d12_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ typedef struct
pass_semantics_t semantics;
uint32_t frame_count;
int32_t frame_direction;
uint32_t frame_time_delta;
float original_fps;
uint32_t rotation;
uint32_t total_subframes;
uint32_t current_subframe;
Expand Down
6 changes: 6 additions & 0 deletions gfx/drivers/d3d10.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,8 @@ static bool d3d10_gfx_set_shader(void* data,
&d3d10->frame.output_size, /* FinalViewportSize */
&d3d10->pass[i].frame_count, /* FrameCount */
&d3d10->pass[i].frame_direction, /* FrameDirection */
&d3d10->pass[i].frame_time_delta,/* FrameTimeDelta */
&d3d10->pass[i].original_fps, /* OriginalFPS */
&d3d10->pass[i].rotation, /* Rotation */
&d3d10->pass[i].core_aspect, /* OriginalAspect */
&d3d10->pass[i].core_aspect_rot, /* OriginalAspectRotated */
Expand Down Expand Up @@ -2331,6 +2333,10 @@ static bool d3d10_gfx_frame(
d3d10->pass[i].frame_direction = 1;
#endif

d3d10->pass[i].frame_time_delta = video_driver_get_frame_time_delta_usec();

d3d10->pass[i].original_fps = video_driver_get_original_fps();

d3d10->pass[i].rotation = retroarch_get_rotation();

d3d10->pass[i].core_aspect = video_driver_get_core_aspect();
Expand Down
5 changes: 5 additions & 0 deletions gfx/drivers/d3d11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,8 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
&d3d11->frame.output_size, /* FinalViewportSize */
&d3d11->pass[i].frame_count, /* FrameCount */
&d3d11->pass[i].frame_direction, /* FrameDirection */
&d3d11->pass[i].frame_time_delta,/* FrameTimeDelta */
&d3d11->pass[i].original_fps, /* OriginalFPS */
&d3d11->pass[i].rotation, /* Rotation */
&d3d11->pass[i].core_aspect, /* OriginalAspect */
&d3d11->pass[i].core_aspect_rot, /* OriginalAspectRotated */
Expand Down Expand Up @@ -3093,6 +3095,9 @@ static bool d3d11_gfx_frame(
#else
d3d11->pass[i].frame_direction = 1;
#endif
d3d11->pass[i].frame_time_delta = video_driver_get_frame_time_delta_usec();

d3d11->pass[i].original_fps = video_driver_get_original_fps();

d3d11->pass[i].rotation = retroarch_get_rotation();

Expand Down
8 changes: 7 additions & 1 deletion gfx/drivers/d3d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,8 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
&d3d12->frame.output_size, /* FinalViewportSize */
&d3d12->pass[i].frame_count, /* FrameCount */
&d3d12->pass[i].frame_direction, /* FrameDirection */
&d3d12->pass[i].frame_time_delta,/* FrameTimeDelta */
&d3d12->pass[i].original_fps, /* OriginalFPS */
&d3d12->pass[i].rotation, /* Rotation */
&d3d12->pass[i].core_aspect, /* OriginalAspect */
&d3d12->pass[i].core_aspect_rot, /* OriginalAspectRotated */
Expand Down Expand Up @@ -3593,7 +3595,11 @@ static bool d3d12_gfx_frame(
d3d12->pass[i].frame_direction = -1;
else
#endif
d3d12->pass[i].frame_direction = 1;
d3d12->pass[i].frame_direction = 1;

d3d12->pass[i].frame_time_delta = video_driver_get_frame_time_delta_usec();

d3d12->pass[i].original_fps = video_driver_get_original_fps();

d3d12->pass[i].rotation = retroarch_get_rotation();

Expand Down
26 changes: 13 additions & 13 deletions gfx/drivers/gl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3559,19 +3559,19 @@ static bool gl2_frame(void *data, const void *frame,

glClear(GL_COLOR_BUFFER_BIT);

params.data = gl;
params.width = frame_width;
params.height = frame_height;
params.tex_width = gl->tex_w;
params.tex_height = gl->tex_h;
params.out_width = gl->vp.width;
params.out_height = gl->vp.height;
params.frame_counter = (unsigned int)frame_count;
params.info = &gl->tex_info;
params.prev_info = gl->prev_info;
params.feedback_info = &feedback_info;
params.fbo_info = NULL;
params.fbo_info_cnt = 0;
params.data = gl;
params.width = frame_width;
params.height = frame_height;
params.tex_width = gl->tex_w;
params.tex_height = gl->tex_h;
params.out_width = gl->vp.width;
params.out_height = gl->vp.height;
params.frame_counter = (unsigned int)frame_count;
params.info = &gl->tex_info;
params.prev_info = gl->prev_info;
params.feedback_info = &feedback_info;
params.fbo_info = NULL;
params.fbo_info_cnt = 0;

gl->shader->set_params(&params, gl->shader_data);

Expand Down
4 changes: 4 additions & 0 deletions gfx/drivers/gl3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,10 @@ static bool gl3_frame(void *data, const void *frame,
#else
gl3_filter_chain_set_frame_direction(gl->filter_chain, 1);
#endif
gl3_filter_chain_set_frame_time_delta(gl->filter_chain, video_driver_get_frame_time_delta_usec());

gl3_filter_chain_set_original_fps(gl->filter_chain, video_driver_get_original_fps());

gl3_filter_chain_set_rotation(gl->filter_chain, retroarch_get_rotation());

gl3_filter_chain_set_core_aspect(gl->filter_chain, video_driver_get_core_aspect());
Expand Down
26 changes: 23 additions & 3 deletions gfx/drivers/gx2_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,8 @@ static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigne
static void gx2_update_uniform_block(wiiu_video_t *wiiu,
int pass, float *ubo, int id,
int size, int uniformVarCount, GX2UniformVar *uniformVars,
uint64_t frame_count, int32_t frame_direction, uint32_t rotation, float core_aspect, float core_aspect_rot)
uint64_t frame_count, int32_t frame_direction, uint32_t rotation, float core_aspect,
float core_aspect_rot, uint32_t frame_time_delta, uint32_t original_fps)
{
unsigned i;
for (i = 0; i < uniformVarCount; i++)
Expand Down Expand Up @@ -1716,6 +1717,19 @@ static void gx2_update_uniform_block(wiiu_video_t *wiiu,
continue;
}

if (string_is_equal(id, "FrameTimeDelta"))
{
*dst = frame_time_delta;
*(u32 *)dst = __builtin_bswap32(*(u32 *)dst);
continue;
}

if (string_is_equal(id, "OriginalFPS"))
{
*dst = original_fps;
continue;
}

if (string_is_equal(id, "Rotation"))
{
*dst = rotation;
Expand Down Expand Up @@ -1950,6 +1964,11 @@ static bool gx2_frame(void *data, const void *frame,
#else
int32_t frame_direction = 1;
#endif

uint32_t frame_time_delta = video_driver_get_frame_time_delta_usec();

float original_fps = video_driver_get_original_fps();

uint32_t rotation = retroarch_get_rotation();

float core_aspect = video_driver_get_core_aspect();
Expand All @@ -1969,7 +1988,8 @@ static bool gx2_frame(void *data, const void *frame,
gx2_update_uniform_block(wiiu, i, wiiu->pass[i].vs_ubos[j], j,
wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars,
frame_count, frame_direction, rotation, core_aspect, core_aspect_rot);
frame_count, frame_direction, rotation, core_aspect, core_aspect_rot,frame_time_delta, original_fps);

GX2SetVertexUniformBlock(wiiu->pass[i].gfd->vs->uniformBlocks[j].offset,
wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]);
}
Expand All @@ -1981,7 +2001,7 @@ static bool gx2_frame(void *data, const void *frame,
gx2_update_uniform_block(wiiu, i, wiiu->pass[i].ps_ubos[j], j,
wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars,
frame_count, frame_direction, rotation, core_aspect, core_aspect_rot);
frame_count, frame_direction, rotation, core_aspect, core_aspect_rot,frame_time_delta, original_fps);
GX2SetPixelUniformBlock(wiiu->pass[i].gfd->ps->uniformBlocks[j].offset,
wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]);
}
Expand Down
10 changes: 9 additions & 1 deletion gfx/drivers/metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,8 @@ typedef struct MTLALIGN(16)
texture_t feedback;
uint32_t frame_count;
int32_t frame_direction;
int32_t frame_time_delta;
float original_fps;
uint32_t rotation;
float_t core_aspect;
float_t core_aspect_rot;
Expand Down Expand Up @@ -1576,9 +1578,13 @@ - (void)drawWithContext:(Context *)ctx
_engine.pass[i].frame_direction = -1;
else
#else
_engine.pass[i].frame_direction = 1;
_engine.pass[i].frame_direction = 1;
#endif

_engine.pass[i].frame_time_delta = video_driver_get_frame_time_delta_usec();

_engine.pass[i].original_fps = video_driver_get_original_fps();

_engine.pass[i].rotation = retroarch_get_rotation();

_engine.pass[i].core_aspect = video_driver_get_core_aspect();
Expand Down Expand Up @@ -1846,6 +1852,8 @@ - (BOOL)setShaderFromPath:(NSString *)path
&_engine.frame.output_size, /* FinalViewportSize */
&_engine.pass[i].frame_count, /* FrameCount */
&_engine.pass[i].frame_direction, /* FrameDirection */
&_engine.pass[i].frame_time_delta,/* FrameTimeDelta */
&_engine.pass[i].original_fps, /* OriginalFPS */
&_engine.pass[i].rotation, /* Rotation */
&_engine.pass[i].core_aspect, /* OriginalAspect */
&_engine.pass[i].core_aspect_rot, /* OriginalAspectRotated */
Expand Down
6 changes: 6 additions & 0 deletions gfx/drivers/vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -4571,6 +4571,12 @@ static bool vulkan_frame(void *data, const void *frame,
(vulkan_filter_chain_t*)vk->filter_chain,
1);
#endif
vulkan_filter_chain_set_frame_time_delta(
(vulkan_filter_chain_t*)vk->filter_chain, video_driver_get_frame_time_delta_usec());

vulkan_filter_chain_set_original_fps(
(vulkan_filter_chain_t*)vk->filter_chain, video_driver_get_original_fps());

vulkan_filter_chain_set_rotation(
(vulkan_filter_chain_t*)vk->filter_chain, retroarch_get_rotation());

Expand Down
3 changes: 3 additions & 0 deletions gfx/drivers_shader/glslang_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ bool glslang_read_shader_file(const char *path,
if (!string_list_append(output, "#define _HAS_ORIGINALASPECT_UNIFORMS", attr))
goto error;

if (!string_list_append(output, "#define _HAS_FRAMETIME_UNIFORMS", attr))
goto error;

/* At least VIM treats the first line as line #1,
* so offset everything by one. */
snprintf(tmp, sizeof(tmp), "#line %u \"%s\"", root_file ? 2 : 1, basename);
Expand Down
50 changes: 50 additions & 0 deletions gfx/drivers_shader/shader_gl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,16 @@ class Pass
frame_direction = direction;
}

void set_frame_time_delta(uint32_t time_delta)
{
frame_time_delta = time_delta;
}

void set_original_fps(float fps)
{
original_fps = fps;
}

void set_rotation(uint32_t rot)
{
rotation = rot;
Expand Down Expand Up @@ -883,6 +893,8 @@ class Pass
uint64_t frame_count = 0;
unsigned frame_count_period = 0;
int32_t frame_direction = 1;
uint32_t frame_time_delta = 0;
float original_fps = 0;
uint32_t rotation = 0;
float core_aspect = 0;
float core_aspect_rot = 0;
Expand Down Expand Up @@ -1093,6 +1105,8 @@ bool Pass::init_pipeline()
reflect_parameter("FinalViewportSize", reflection.semantics[SLANG_SEMANTIC_FINAL_VIEWPORT]);
reflect_parameter("FrameCount", reflection.semantics[SLANG_SEMANTIC_FRAME_COUNT]);
reflect_parameter("FrameDirection", reflection.semantics[SLANG_SEMANTIC_FRAME_DIRECTION]);
reflect_parameter("FrameTimeDelta", reflection.semantics[SLANG_SEMANTIC_FRAME_TIME_DELTA]);
reflect_parameter("OriginalFPS", reflection.semantics[SLANG_SEMANTIC_ORIGINAL_FPS]);
reflect_parameter("Rotation", reflection.semantics[SLANG_SEMANTIC_ROTATION]);
reflect_parameter("OriginalAspect", reflection.semantics[SLANG_SEMANTIC_CORE_ASPECT]);
reflect_parameter("OriginalAspectRotated", reflection.semantics[SLANG_SEMANTIC_CORE_ASPECT_ROT]);
Expand Down Expand Up @@ -1560,6 +1574,12 @@ void Pass::build_semantics(uint8_t *buffer,
build_semantic_int(buffer, SLANG_SEMANTIC_FRAME_DIRECTION,
frame_direction);

build_semantic_uint(buffer, SLANG_SEMANTIC_FRAME_TIME_DELTA,
frame_time_delta);

build_semantic_float(buffer, SLANG_SEMANTIC_ORIGINAL_FPS,
original_fps);

build_semantic_uint(buffer, SLANG_SEMANTIC_ROTATION,
rotation);

Expand Down Expand Up @@ -1817,6 +1837,8 @@ struct gl3_filter_chain
void set_frame_count(uint64_t count);
void set_frame_count_period(unsigned pass, unsigned period);
void set_frame_direction(int32_t direction);
void set_frame_time_delta(uint32_t rot);
void set_original_fps(float fps);
void set_rotation(uint32_t rot);
void set_core_aspect(float coreaspect);
void set_core_aspect_rot(float coreaspectrot);
Expand Down Expand Up @@ -2308,6 +2330,20 @@ void gl3_filter_chain::set_frame_direction(int32_t direction)
passes[i]->set_frame_direction(direction);
}

void gl3_filter_chain::set_frame_time_delta(uint32_t time_delta)
{
unsigned i;
for (i = 0; i < passes.size(); i++)
passes[i]->set_frame_time_delta(time_delta);
}

void gl3_filter_chain::set_original_fps(float fps)
{
unsigned i;
for (i = 0; i < passes.size(); i++)
passes[i]->set_original_fps(fps);
}

void gl3_filter_chain::set_rotation(uint32_t rot)
{
unsigned i;
Expand Down Expand Up @@ -2766,6 +2802,20 @@ void gl3_filter_chain_set_frame_direction(
chain->set_frame_direction(direction);
}

void gl3_filter_chain_set_frame_time_delta(
gl3_filter_chain_t *chain,
uint32_t time_delta)
{
chain->set_frame_time_delta(time_delta);
}

void gl3_filter_chain_set_original_fps(
gl3_filter_chain_t *chain,
float fps)
{
chain->set_original_fps(fps);
}

void gl3_filter_chain_set_rotation(
gl3_filter_chain_t *chain,
uint32_t rot)
Expand Down
8 changes: 8 additions & 0 deletions gfx/drivers_shader/shader_gl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ void gl3_filter_chain_set_frame_direction(
gl3_filter_chain_t *chain,
int32_t direction);

void gl3_filter_chain_set_frame_time_delta(
gl3_filter_chain_t *chain,
uint32_t time_delta);

void gl3_filter_chain_set_original_fps(
gl3_filter_chain_t *chain,
float fps);

void gl3_filter_chain_set_rotation(
gl3_filter_chain_t *chain,
uint32_t rotation);
Expand Down
Loading
Loading