Add Frametime Uniforms (#17155)
Some checks failed
CI 3DS / build (push) Waiting to run
CI Android / build (push) Waiting to run
CI DOS/DJGPP / build (push) Waiting to run
CI Emscripten / build (push) Waiting to run
CI GameCube / build (push) Waiting to run
CI Linux (i686) / build (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI Miyoo ARM32 / build (push) Waiting to run
CI PS2 / build (push) Waiting to run
CI PS4/ORBIS / build (push) Waiting to run
CI PSP / build (push) Waiting to run
CI PSVita / build (push) Waiting to run
CI RS90 Odbeta MIPS32 / build (push) Waiting to run
CI RetroFW MIPS32 / build (push) Waiting to run
CI Switch/libnx / build (push) Waiting to run
CI Wii / build (push) Waiting to run
CI WiiU / build (push) Waiting to run
CI Windows i686 (MXE) / build (push) Waiting to run
CI Windows x64 (MXE) / build (push) Waiting to run
RetroArch CI / linux-c89 (push) Waiting to run
CI webOS / build (push) Waiting to run
Crowdin Daily Workflow / sync (push) Has been cancelled

* Initial implementation of CoreAspect uniform

* float -> float_t

* Possibly fix wii_u building

* vulkan: use float instead of float_t;

* slangp: Advertise support of CoreAspect uniform
by defining _RARCH_HAS_COREASPECT_UNIFORM early in the shader source, just after "#extension GL_GOOGLE_cpp_style_line_directive : require"

* CoreAspect + glsl fix: use glUniform1f()

* Add CoreAspectRot uniform.
It reports CoreAspect value or 1/CoreAspect when the content is rotated by 90 or 270 deg.

* Fixed stupid typo

* Just use _HAS_COREASPECT_UNIFORMS to check for CoreAspect uniforms support (was _RARCH_HAS_COREASPECT_UNIFORMS)

* Rename CoreAspect, CoreAspectRot, _HAS_COREASPECT_UNIFORMS to OriginalAspect, OriginlAspectRot, _HAS_ORIGINALASPECT_UNIFORMS

* GLCore: void Pass::build_semantic_float needs glUniform1f.
...how on earth did it worked for UBO !?

* d3d10,11,12, wrong function called by overlook.

* Add test shader, will remove that before PR

* Fix metal rotated aspect reporting

* remove test shader

* Fix C89 Build

* Use OriginalAspectRotated instead of OriginalAspectRot

* Add CoreFPS and FrameTimeDelta Uniforms.
_HAS_ORIGINALASPECT_UNIFORMS is (#)defined and can be used to query for them.

* add test shader

* remote test shader

* Wrong paste.

* gx2: use float

* wrong indentation

* resolved merge conflict

* fix indentation

* Fix comment/Formatting

* Change uniform name from CoreFPS to OriginalFPS

* underliyng references: core_fps -> original_fps
This commit is contained in:
Antonio Orefice 2024-11-13 04:50:59 +01:00 committed by GitHub
parent 94525363f0
commit 2a56a827e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 268 additions and 43 deletions

View File

@ -215,6 +215,8 @@ typedef struct
pass_semantics_t semantics; pass_semantics_t semantics;
uint32_t frame_count; uint32_t frame_count;
int32_t frame_direction; int32_t frame_direction;
uint32_t frame_time_delta;
float original_fps;
uint32_t rotation; uint32_t rotation;
uint32_t total_subframes; uint32_t total_subframes;
uint32_t current_subframe; uint32_t current_subframe;

View File

@ -291,6 +291,8 @@ typedef struct
pass_semantics_t semantics; pass_semantics_t semantics;
uint32_t frame_count; uint32_t frame_count;
int32_t frame_direction; int32_t frame_direction;
uint32_t frame_time_delta;
float original_fps;
uint32_t rotation; uint32_t rotation;
uint32_t total_subframes; uint32_t total_subframes;
uint32_t current_subframe; uint32_t current_subframe;

View File

@ -328,6 +328,8 @@ typedef struct
pass_semantics_t semantics; pass_semantics_t semantics;
uint32_t frame_count; uint32_t frame_count;
int32_t frame_direction; int32_t frame_direction;
uint32_t frame_time_delta;
float original_fps;
uint32_t rotation; uint32_t rotation;
uint32_t total_subframes; uint32_t total_subframes;
uint32_t current_subframe; uint32_t current_subframe;

View File

@ -1335,6 +1335,8 @@ static bool d3d10_gfx_set_shader(void* data,
&d3d10->frame.output_size, /* FinalViewportSize */ &d3d10->frame.output_size, /* FinalViewportSize */
&d3d10->pass[i].frame_count, /* FrameCount */ &d3d10->pass[i].frame_count, /* FrameCount */
&d3d10->pass[i].frame_direction, /* FrameDirection */ &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].rotation, /* Rotation */
&d3d10->pass[i].core_aspect, /* OriginalAspect */ &d3d10->pass[i].core_aspect, /* OriginalAspect */
&d3d10->pass[i].core_aspect_rot, /* OriginalAspectRotated */ &d3d10->pass[i].core_aspect_rot, /* OriginalAspectRotated */
@ -2331,6 +2333,10 @@ static bool d3d10_gfx_frame(
d3d10->pass[i].frame_direction = 1; d3d10->pass[i].frame_direction = 1;
#endif #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].rotation = retroarch_get_rotation();
d3d10->pass[i].core_aspect = video_driver_get_core_aspect(); d3d10->pass[i].core_aspect = video_driver_get_core_aspect();

View File

@ -1537,6 +1537,8 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
&d3d11->frame.output_size, /* FinalViewportSize */ &d3d11->frame.output_size, /* FinalViewportSize */
&d3d11->pass[i].frame_count, /* FrameCount */ &d3d11->pass[i].frame_count, /* FrameCount */
&d3d11->pass[i].frame_direction, /* FrameDirection */ &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].rotation, /* Rotation */
&d3d11->pass[i].core_aspect, /* OriginalAspect */ &d3d11->pass[i].core_aspect, /* OriginalAspect */
&d3d11->pass[i].core_aspect_rot, /* OriginalAspectRotated */ &d3d11->pass[i].core_aspect_rot, /* OriginalAspectRotated */
@ -3093,6 +3095,9 @@ static bool d3d11_gfx_frame(
#else #else
d3d11->pass[i].frame_direction = 1; d3d11->pass[i].frame_direction = 1;
#endif #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(); d3d11->pass[i].rotation = retroarch_get_rotation();

View File

@ -1724,6 +1724,8 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
&d3d12->frame.output_size, /* FinalViewportSize */ &d3d12->frame.output_size, /* FinalViewportSize */
&d3d12->pass[i].frame_count, /* FrameCount */ &d3d12->pass[i].frame_count, /* FrameCount */
&d3d12->pass[i].frame_direction, /* FrameDirection */ &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].rotation, /* Rotation */
&d3d12->pass[i].core_aspect, /* OriginalAspect */ &d3d12->pass[i].core_aspect, /* OriginalAspect */
&d3d12->pass[i].core_aspect_rot, /* OriginalAspectRotated */ &d3d12->pass[i].core_aspect_rot, /* OriginalAspectRotated */
@ -3595,6 +3597,10 @@ static bool d3d12_gfx_frame(
#endif #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(); d3d12->pass[i].rotation = retroarch_get_rotation();
d3d12->pass[i].core_aspect = video_driver_get_core_aspect(); d3d12->pass[i].core_aspect = video_driver_get_core_aspect();

View File

@ -2742,6 +2742,10 @@ static bool gl3_frame(void *data, const void *frame,
#else #else
gl3_filter_chain_set_frame_direction(gl->filter_chain, 1); gl3_filter_chain_set_frame_direction(gl->filter_chain, 1);
#endif #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_rotation(gl->filter_chain, retroarch_get_rotation());
gl3_filter_chain_set_core_aspect(gl->filter_chain, video_driver_get_core_aspect()); gl3_filter_chain_set_core_aspect(gl->filter_chain, video_driver_get_core_aspect());

View File

@ -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, static void gx2_update_uniform_block(wiiu_video_t *wiiu,
int pass, float *ubo, int id, int pass, float *ubo, int id,
int size, int uniformVarCount, GX2UniformVar *uniformVars, 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; unsigned i;
for (i = 0; i < uniformVarCount; i++) for (i = 0; i < uniformVarCount; i++)
@ -1716,6 +1717,19 @@ static void gx2_update_uniform_block(wiiu_video_t *wiiu,
continue; 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")) if (string_is_equal(id, "Rotation"))
{ {
*dst = rotation; *dst = rotation;
@ -1950,6 +1964,11 @@ static bool gx2_frame(void *data, const void *frame,
#else #else
int32_t frame_direction = 1; int32_t frame_direction = 1;
#endif #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(); uint32_t rotation = retroarch_get_rotation();
float core_aspect = video_driver_get_core_aspect(); float core_aspect = video_driver_get_core_aspect();
@ -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, 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->uniformBlocks[j].size,
wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars, 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, GX2SetVertexUniformBlock(wiiu->pass[i].gfd->vs->uniformBlocks[j].offset,
wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]); wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]);
} }
@ -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, 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->uniformBlocks[j].size,
wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars, 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, GX2SetPixelUniformBlock(wiiu->pass[i].gfd->ps->uniformBlocks[j].offset,
wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]); wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]);
} }

View File

@ -1205,6 +1205,8 @@ typedef struct MTLALIGN(16)
texture_t feedback; texture_t feedback;
uint32_t frame_count; uint32_t frame_count;
int32_t frame_direction; int32_t frame_direction;
int32_t frame_time_delta;
float original_fps;
uint32_t rotation; uint32_t rotation;
float_t core_aspect; float_t core_aspect;
float_t core_aspect_rot; float_t core_aspect_rot;
@ -1579,6 +1581,10 @@ typedef struct MTLALIGN(16)
_engine.pass[i].frame_direction = 1; _engine.pass[i].frame_direction = 1;
#endif #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].rotation = retroarch_get_rotation();
_engine.pass[i].core_aspect = video_driver_get_core_aspect(); _engine.pass[i].core_aspect = video_driver_get_core_aspect();
@ -1846,6 +1852,8 @@ typedef struct MTLALIGN(16)
&_engine.frame.output_size, /* FinalViewportSize */ &_engine.frame.output_size, /* FinalViewportSize */
&_engine.pass[i].frame_count, /* FrameCount */ &_engine.pass[i].frame_count, /* FrameCount */
&_engine.pass[i].frame_direction, /* FrameDirection */ &_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].rotation, /* Rotation */
&_engine.pass[i].core_aspect, /* OriginalAspect */ &_engine.pass[i].core_aspect, /* OriginalAspect */
&_engine.pass[i].core_aspect_rot, /* OriginalAspectRotated */ &_engine.pass[i].core_aspect_rot, /* OriginalAspectRotated */

View File

@ -4571,6 +4571,12 @@ static bool vulkan_frame(void *data, const void *frame,
(vulkan_filter_chain_t*)vk->filter_chain, (vulkan_filter_chain_t*)vk->filter_chain,
1); 1);
#endif #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_set_rotation(
(vulkan_filter_chain_t*)vk->filter_chain, retroarch_get_rotation()); (vulkan_filter_chain_t*)vk->filter_chain, retroarch_get_rotation());

View File

@ -181,6 +181,9 @@ bool glslang_read_shader_file(const char *path,
if (!string_list_append(output, "#define _HAS_ORIGINALASPECT_UNIFORMS", attr)) if (!string_list_append(output, "#define _HAS_ORIGINALASPECT_UNIFORMS", attr))
goto error; goto error;
if (!string_list_append(output, "#define _HAS_FRAMETIME_UNIFORMS", attr))
goto error;
/* At least VIM treats the first line as line #1, /* At least VIM treats the first line as line #1,
* so offset everything by one. */ * so offset everything by one. */
snprintf(tmp, sizeof(tmp), "#line %u \"%s\"", root_file ? 2 : 1, basename); snprintf(tmp, sizeof(tmp), "#line %u \"%s\"", root_file ? 2 : 1, basename);

View File

@ -752,6 +752,16 @@ public:
frame_direction = direction; 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) void set_rotation(uint32_t rot)
{ {
rotation = rot; rotation = rot;
@ -883,6 +893,8 @@ private:
uint64_t frame_count = 0; uint64_t frame_count = 0;
unsigned frame_count_period = 0; unsigned frame_count_period = 0;
int32_t frame_direction = 1; int32_t frame_direction = 1;
uint32_t frame_time_delta = 0;
float original_fps = 0;
uint32_t rotation = 0; uint32_t rotation = 0;
float core_aspect = 0; float core_aspect = 0;
float core_aspect_rot = 0; float core_aspect_rot = 0;
@ -1093,6 +1105,8 @@ bool Pass::init_pipeline()
reflect_parameter("FinalViewportSize", reflection.semantics[SLANG_SEMANTIC_FINAL_VIEWPORT]); reflect_parameter("FinalViewportSize", reflection.semantics[SLANG_SEMANTIC_FINAL_VIEWPORT]);
reflect_parameter("FrameCount", reflection.semantics[SLANG_SEMANTIC_FRAME_COUNT]); reflect_parameter("FrameCount", reflection.semantics[SLANG_SEMANTIC_FRAME_COUNT]);
reflect_parameter("FrameDirection", reflection.semantics[SLANG_SEMANTIC_FRAME_DIRECTION]); 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("Rotation", reflection.semantics[SLANG_SEMANTIC_ROTATION]);
reflect_parameter("OriginalAspect", reflection.semantics[SLANG_SEMANTIC_CORE_ASPECT]); reflect_parameter("OriginalAspect", reflection.semantics[SLANG_SEMANTIC_CORE_ASPECT]);
reflect_parameter("OriginalAspectRotated", reflection.semantics[SLANG_SEMANTIC_CORE_ASPECT_ROT]); reflect_parameter("OriginalAspectRotated", reflection.semantics[SLANG_SEMANTIC_CORE_ASPECT_ROT]);
@ -1560,6 +1574,12 @@ void Pass::build_semantics(uint8_t *buffer,
build_semantic_int(buffer, SLANG_SEMANTIC_FRAME_DIRECTION, build_semantic_int(buffer, SLANG_SEMANTIC_FRAME_DIRECTION,
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, build_semantic_uint(buffer, SLANG_SEMANTIC_ROTATION,
rotation); rotation);
@ -1817,6 +1837,8 @@ public:
void set_frame_count(uint64_t count); void set_frame_count(uint64_t count);
void set_frame_count_period(unsigned pass, unsigned period); void set_frame_count_period(unsigned pass, unsigned period);
void set_frame_direction(int32_t direction); 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_rotation(uint32_t rot);
void set_core_aspect(float coreaspect); void set_core_aspect(float coreaspect);
void set_core_aspect_rot(float coreaspectrot); void set_core_aspect_rot(float coreaspectrot);
@ -2308,6 +2330,20 @@ void gl3_filter_chain::set_frame_direction(int32_t direction)
passes[i]->set_frame_direction(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) void gl3_filter_chain::set_rotation(uint32_t rot)
{ {
unsigned i; unsigned i;
@ -2766,6 +2802,20 @@ void gl3_filter_chain_set_frame_direction(
chain->set_frame_direction(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( void gl3_filter_chain_set_rotation(
gl3_filter_chain_t *chain, gl3_filter_chain_t *chain,
uint32_t rot) uint32_t rot)

View File

@ -115,6 +115,14 @@ void gl3_filter_chain_set_frame_direction(
gl3_filter_chain_t *chain, gl3_filter_chain_t *chain,
int32_t direction); 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( void gl3_filter_chain_set_rotation(
gl3_filter_chain_t *chain, gl3_filter_chain_t *chain,
uint32_t rotation); uint32_t rotation);

View File

@ -98,6 +98,8 @@ struct shader_uniforms
int frame_count; int frame_count;
int frame_direction; int frame_direction;
int frame_time_delta;
float original_fps;
/* Use int for maximal compatibility despite other drivers using uint. */ /* Use int for maximal compatibility despite other drivers using uint. */
int rotation; int rotation;
@ -489,7 +491,7 @@ static bool gl_glsl_compile_program(
if (!gl_glsl_compile_shader( if (!gl_glsl_compile_shader(
glsl, glsl,
program->vprg, program->vprg,
"#define VERTEX\n#define PARAMETER_UNIFORM\n#define _HAS_ORIGINALASPECT_UNIFORMS\n", "#define VERTEX\n#define PARAMETER_UNIFORM\n#define _HAS_ORIGINALASPECT_UNIFORMS\n#define _HAS_FRAMETIME_UNIFORMS\n",
program_info->vertex)) program_info->vertex))
{ {
RARCH_ERR("Failed to compile vertex shader #%u\n", idx); RARCH_ERR("Failed to compile vertex shader #%u\n", idx);
@ -504,7 +506,7 @@ static bool gl_glsl_compile_program(
RARCH_LOG("[GLSL]: Found GLSL fragment shader.\n"); RARCH_LOG("[GLSL]: Found GLSL fragment shader.\n");
program->fprg = glCreateShader(GL_FRAGMENT_SHADER); program->fprg = glCreateShader(GL_FRAGMENT_SHADER);
if (!gl_glsl_compile_shader(glsl, program->fprg, if (!gl_glsl_compile_shader(glsl, program->fprg,
"#define FRAGMENT\n#define PARAMETER_UNIFORM\n#define _HAS_ORIGINALASPECT_UNIFORMS\n", "#define FRAGMENT\n#define PARAMETER_UNIFORM\n#define _HAS_ORIGINALASPECT_UNIFORMS\n#define _HAS_FRAMETIME_UNIFORMS\n",
program_info->fragment)) program_info->fragment))
{ {
RARCH_ERR("Failed to compile fragment shader #%u\n", idx); RARCH_ERR("Failed to compile fragment shader #%u\n", idx);
@ -740,6 +742,7 @@ static void gl_glsl_find_uniforms(glsl_shader_data_t *glsl,
#if defined(VITA) #if defined(VITA)
uni->time = gl_glsl_get_uniform(glsl, prog, "Time"); uni->time = gl_glsl_get_uniform(glsl, prog, "Time");
#endif #endif
uni->mvp = gl_glsl_get_uniform(glsl, prog, "MVPMatrix"); uni->mvp = gl_glsl_get_uniform(glsl, prog, "MVPMatrix");
uni->tex_coord = gl_glsl_get_attrib(glsl, prog, "TexCoord"); uni->tex_coord = gl_glsl_get_attrib(glsl, prog, "TexCoord");
uni->vertex_coord = gl_glsl_get_attrib(glsl, prog, "VertexCoord"); uni->vertex_coord = gl_glsl_get_attrib(glsl, prog, "VertexCoord");
@ -753,9 +756,12 @@ static void gl_glsl_find_uniforms(glsl_shader_data_t *glsl,
uni->frame_count = gl_glsl_get_uniform(glsl, prog, "FrameCount"); uni->frame_count = gl_glsl_get_uniform(glsl, prog, "FrameCount");
uni->frame_direction = gl_glsl_get_uniform(glsl, prog, "FrameDirection"); uni->frame_direction = gl_glsl_get_uniform(glsl, prog, "FrameDirection");
uni->frame_time_delta = gl_glsl_get_uniform(glsl, prog, "FrameTimeDelta");
uni->original_fps = gl_glsl_get_uniform(glsl, prog, "OriginalFPS");
uni->rotation = gl_glsl_get_uniform(glsl, prog, "Rotation"); uni->rotation = gl_glsl_get_uniform(glsl, prog, "Rotation");
uni->core_aspect = gl_glsl_get_uniform(glsl, prog, "OriginalAspect"); uni->core_aspect = gl_glsl_get_uniform(glsl, prog, "OriginalAspect");
uni->core_aspect_rot = gl_glsl_get_uniform(glsl, prog, "OriginalAspectRotated"); uni->core_aspect_rot = gl_glsl_get_uniform(glsl, prog, "OriginalAspectRotAted");
for (i = 0; i < glsl->shader->luts; i++) for (i = 0; i < glsl->shader->luts; i++)
uni->lut_texture[i] = glGetUniformLocation(prog, glsl->shader->lut[i].id); uni->lut_texture[i] = glGetUniformLocation(prog, glsl->shader->lut[i].id);
@ -1361,6 +1367,12 @@ static void gl_glsl_set_params(void *dat, void *shader_data)
glUniform1i(uni->frame_direction, 1); glUniform1i(uni->frame_direction, 1);
} }
if (uni->frame_time_delta >= 0)
glUniform1i(uni->frame_time_delta, video_driver_get_frame_time_delta_usec());
if (uni->original_fps >= 0)
glUniform1f(uni->original_fps, video_driver_get_original_fps());
if (uni->rotation >= 0) if (uni->rotation >= 0)
glUniform1i(uni->rotation, retroarch_get_rotation()); glUniform1i(uni->rotation, retroarch_get_rotation());

View File

@ -253,6 +253,8 @@ class Pass
void set_simulate_scanline(bool simulate) { simulate_scanline = simulate; } void set_simulate_scanline(bool simulate) { simulate_scanline = simulate; }
#endif /* VULKAN_ROLLING_SCANLINE_SIMULATION */ #endif /* VULKAN_ROLLING_SCANLINE_SIMULATION */
void set_frame_direction(int32_t dir) { frame_direction = dir; } void set_frame_direction(int32_t dir) { frame_direction = dir; }
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; } void set_rotation(uint32_t rot) { rotation = rot; }
void set_core_aspect(float coreaspect) { core_aspect = coreaspect; } void set_core_aspect(float coreaspect) { core_aspect = coreaspect; }
void set_core_aspect_rot(float coreaspectrot) { core_aspect_rot = coreaspectrot; } void set_core_aspect_rot(float coreaspectrot) { core_aspect_rot = coreaspectrot; }
@ -345,6 +347,8 @@ class Pass
uint64_t frame_count = 0; uint64_t frame_count = 0;
int32_t frame_direction = 1; int32_t frame_direction = 1;
uint32_t frame_time_delta = 0;
float original_fps = 0;
uint32_t rotation = 0; uint32_t rotation = 0;
float core_aspect = 0; float core_aspect = 0;
float core_aspect_rot = 0; float core_aspect_rot = 0;
@ -415,6 +419,8 @@ struct vulkan_filter_chain
void set_simulate_scanline(bool simulate_scanline); void set_simulate_scanline(bool simulate_scanline);
#endif /* VULKAN_ROLLING_SCANLINE_SIMULATION */ #endif /* VULKAN_ROLLING_SCANLINE_SIMULATION */
void set_frame_direction(int32_t direction); void set_frame_direction(int32_t direction);
void set_frame_time_delta(uint32_t time_delta);
void set_original_fps(float fps);
void set_rotation(uint32_t rot); void set_rotation(uint32_t rot);
void set_core_aspect(float coreaspect); void set_core_aspect(float coreaspect);
void set_core_aspect_rot(float coreaspect); void set_core_aspect_rot(float coreaspect);
@ -1441,6 +1447,20 @@ void vulkan_filter_chain::set_frame_direction(int32_t direction)
passes[i]->set_frame_direction(direction); passes[i]->set_frame_direction(direction);
} }
void vulkan_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 vulkan_filter_chain::set_original_fps(float fps)
{
unsigned i;
for (i = 0; i < passes.size(); i++)
passes[i]->set_original_fps(fps);
}
void vulkan_filter_chain::set_rotation(uint32_t rot) void vulkan_filter_chain::set_rotation(uint32_t rot)
{ {
unsigned i; unsigned i;
@ -2376,6 +2396,12 @@ void Pass::build_semantics(VkDescriptorSet set, uint8_t *buffer,
build_semantic_uint(buffer, SLANG_SEMANTIC_CURRENT_SUBFRAME, build_semantic_uint(buffer, SLANG_SEMANTIC_CURRENT_SUBFRAME,
current_subframe); current_subframe);
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, build_semantic_uint(buffer, SLANG_SEMANTIC_ROTATION,
rotation); rotation);
@ -3222,6 +3248,20 @@ void vulkan_filter_chain_set_frame_direction(
chain->set_frame_direction(direction); chain->set_frame_direction(direction);
} }
void vulkan_filter_chain_set_frame_time_delta(
vulkan_filter_chain_t *chain,
uint32_t time_delta)
{
chain->set_frame_time_delta(time_delta);
}
void vulkan_filter_chain_set_original_fps(
vulkan_filter_chain_t *chain,
float fps)
{
chain->set_original_fps(fps);
}
void vulkan_filter_chain_set_rotation( void vulkan_filter_chain_set_rotation(
vulkan_filter_chain_t *chain, vulkan_filter_chain_t *chain,
uint32_t rot) uint32_t rot)

View File

@ -136,6 +136,12 @@ void vulkan_filter_chain_set_simulate_scanline(vulkan_filter_chain_t *chain,
void vulkan_filter_chain_set_frame_direction(vulkan_filter_chain_t *chain, void vulkan_filter_chain_set_frame_direction(vulkan_filter_chain_t *chain,
int32_t direction); int32_t direction);
void vulkan_filter_chain_set_frame_time_delta(vulkan_filter_chain_t *chain,
uint32_t time_delta);
void vulkan_filter_chain_set_original_fps(vulkan_filter_chain_t *chain,
float fps);
void vulkan_filter_chain_set_rotation(vulkan_filter_chain_t *chain, void vulkan_filter_chain_set_rotation(vulkan_filter_chain_t *chain,
uint32_t rot); uint32_t rot);

View File

@ -156,6 +156,8 @@ static bool slang_process_reflection(
"FinalViewportSize", "FinalViewportSize",
"FrameCount", "FrameCount",
"FrameDirection", "FrameDirection",
"FrameTimeDelta",
"OriginalFPS",
"Rotation", "Rotation",
"OriginalAspect", "OriginalAspect",
"OriginalAspectRotated", "OriginalAspectRotated",

View File

@ -50,6 +50,8 @@ static const char *semantic_uniform_names[] = {
"FinalViewportSize", "FinalViewportSize",
"FrameCount", "FrameCount",
"FrameDirection", "FrameDirection",
"FrameTimeDelta",
"OriginalFPS",
"Rotation", "Rotation",
"OriginalAspect", "OriginalAspect",
"OriginalAspectRotated", "OriginalAspectRotated",
@ -268,6 +270,16 @@ static bool validate_type_for_semantic(const spirv_cross::SPIRType &type, slang_
&& type.vecsize == 1 && type.vecsize == 1
&& type.columns == 1; && type.columns == 1;
/* uint */ /* uint */
case SLANG_SEMANTIC_FRAME_TIME_DELTA:
return type.basetype == spirv_cross::SPIRType::UInt
&& type.vecsize == 1
&& type.columns == 1;
/* uint */
case SLANG_SEMANTIC_ORIGINAL_FPS:
return type.basetype == spirv_cross::SPIRType::Float
&& type.vecsize == 1
&& type.columns == 1;
/* uint */
case SLANG_SEMANTIC_ROTATION: case SLANG_SEMANTIC_ROTATION:
return type.basetype == spirv_cross::SPIRType::UInt return type.basetype == spirv_cross::SPIRType::UInt
&& type.vecsize == 1 && type.vecsize == 1

View File

@ -70,20 +70,24 @@ enum slang_semantic
SLANG_SEMANTIC_FRAME_COUNT = 3, SLANG_SEMANTIC_FRAME_COUNT = 3,
/* int, frame direction */ /* int, frame direction */
SLANG_SEMANTIC_FRAME_DIRECTION = 4, SLANG_SEMANTIC_FRAME_DIRECTION = 4,
/* uint, FrameTimeDelta */
SLANG_SEMANTIC_FRAME_TIME_DELTA = 5,
/* uint, OriginalFPS */
SLANG_SEMANTIC_ORIGINAL_FPS = 6,
/* uint, rotation */ /* uint, rotation */
SLANG_SEMANTIC_ROTATION = 5, SLANG_SEMANTIC_ROTATION = 7,
/* float, rotation */ /* float, OriginalAspect */
SLANG_SEMANTIC_CORE_ASPECT = 6, SLANG_SEMANTIC_CORE_ASPECT = 8,
SLANG_SEMANTIC_CORE_ASPECT_ROT = 7, /* float, OriginalAspectRotated */
SLANG_SEMANTIC_CORE_ASPECT_ROT = 9,
/* uint, sub frames per content frame */ /* uint, sub frames per content frame */
SLANG_SEMANTIC_TOTAL_SUBFRAMES = 8, SLANG_SEMANTIC_TOTAL_SUBFRAMES = 10,
/* uint, current sub frame */ /* uint, current sub frame */
SLANG_SEMANTIC_CURRENT_SUBFRAME = 9, SLANG_SEMANTIC_CURRENT_SUBFRAME = 11,
SLANG_NUM_BASE_SEMANTICS, SLANG_NUM_BASE_SEMANTICS,
/* float, user defined parameter, arrayed */ /* float, user defined parameter, arrayed */
SLANG_SEMANTIC_FLOAT_PARAMETER = 10, SLANG_SEMANTIC_FLOAT_PARAMETER = 12,
SLANG_NUM_SEMANTICS, SLANG_NUM_SEMANTICS,
SLANG_INVALID_SEMANTIC = -1 SLANG_INVALID_SEMANTIC = -1

View File

@ -1895,6 +1895,29 @@ void video_driver_unset_stub_frame(void)
video_st->frame_bak = NULL; video_st->frame_bak = NULL;
} }
/* Get time diff between frames in usec*/
uint32_t video_driver_get_frame_time_delta_usec(void)
{
static retro_time_t last_time;
retro_time_t now_time;
retro_time_t delta_time;
now_time = cpu_features_get_time_usec();
delta_time = now_time - last_time;
last_time = now_time;
return delta_time;
}
/* Get Original fps (core fps) */
float video_driver_get_original_fps(void)
{
video_driver_state_t *video_st = &video_driver_st;
struct retro_system_av_info *av_info = &video_st->av_info;
float original_fps = (float)video_st->av_info.timing.fps;
return original_fps;
}
/* Get aspect ratio (DAR) requested by the core */ /* Get aspect ratio (DAR) requested by the core */
float video_driver_get_core_aspect(void) float video_driver_get_core_aspect(void)
{ {

View File

@ -915,6 +915,10 @@ void video_driver_unset_stub_frame(void);
float video_driver_get_core_aspect(void); float video_driver_get_core_aspect(void);
uint32_t video_driver_get_frame_time_delta_usec(void);
float video_driver_get_original_fps(void);
void video_driver_set_viewport_core(void); void video_driver_set_viewport_core(void);
void video_driver_set_rgba(void); void video_driver_set_rgba(void);