Add FrameDirection for metal and gx2_gfx

This commit is contained in:
LazyBumHorse 2019-05-29 21:06:44 +02:00
parent b54ad4d67f
commit 9ab49b7b2c
2 changed files with 26 additions and 8 deletions

View File

@ -14,6 +14,7 @@
#include <simd/simd.h> #include <simd/simd.h>
#import <gfx/video_frame.h> #import <gfx/video_frame.h>
#include "../../managers/state_manager.h"
#import "metal_common.h" #import "metal_common.h"
#import "../../ui/drivers/cocoa/cocoa_common.h" #import "../../ui/drivers/cocoa/cocoa_common.h"
@ -552,6 +553,7 @@ typedef struct MTLALIGN(16)
texture_t rt; texture_t rt;
texture_t feedback; texture_t feedback;
uint32_t frame_count; uint32_t frame_count;
int32_t frame_direction;
pass_semantics_t semantics; pass_semantics_t semantics;
MTLViewport viewport; MTLViewport viewport;
__unsafe_unretained id<MTLRenderPipelineState> _state; __unsafe_unretained id<MTLRenderPipelineState> _state;
@ -927,6 +929,8 @@ typedef struct MTLALIGN(16)
if (_shader->pass[i].frame_count_mod) if (_shader->pass[i].frame_count_mod)
_engine.pass[i].frame_count %= _shader->pass[i].frame_count_mod; _engine.pass[i].frame_count %= _shader->pass[i].frame_count_mod;
_engine.pass[i].frame_direction = state_manager_frame_is_reversed() ? -1 : 1;
for (unsigned j = 0; j < SLANG_CBUFFER_MAX; j++) for (unsigned j = 0; j < SLANG_CBUFFER_MAX; j++)
{ {
id<MTLBuffer> buffer = _engine.pass[i].buffers[j]; id<MTLBuffer> buffer = _engine.pass[i].buffers[j];
@ -1180,6 +1184,7 @@ typedef struct MTLALIGN(16)
&_engine.pass[i].rt.size_data, /* OutputSize */ &_engine.pass[i].rt.size_data, /* OutputSize */
&_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 */
} }
}; };
/* clang-format on */ /* clang-format on */

View File

@ -25,6 +25,7 @@
#include "../../configuration.h" #include "../../configuration.h"
#include "../../verbosity.h" #include "../../verbosity.h"
#include "../../retroarch.h" #include "../../retroarch.h"
#include "../../managers/state_manager.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../../config.h" #include "../../config.h"
@ -873,7 +874,8 @@ static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigne
} }
static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *ubo, int id, static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *ubo, int id,
int size, int uniformVarCount, GX2UniformVar *uniformVars, uint64_t frame_count) int size, int uniformVarCount, GX2UniformVar *uniformVars,
uint64_t frame_count, int32_t frame_direction)
{ {
for (int i = 0; i < uniformVarCount; i++) for (int i = 0; i < uniformVarCount; i++)
{ {
@ -916,6 +918,13 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *u
continue; continue;
} }
if (string_is_equal(id, "FrameDirection"))
{
*dst = frame_direction;
*(u32 *)dst = __builtin_bswap32(*(u32 *)dst);
continue;
}
if (string_is_equal(id, "OriginalSize")) if (string_is_equal(id, "OriginalSize"))
{ {
((GX2_vec4 *)dst)->x = wiiu->texture.surface.width; ((GX2_vec4 *)dst)->x = wiiu->texture.surface.width;
@ -1146,6 +1155,8 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
if (wiiu->shader_preset) if (wiiu->shader_preset)
{ {
int32_t frame_direction = state_manager_frame_is_reversed() ? -1 : 1;
for (int i = 0; i < wiiu->shader_preset->passes; i++) for (int i = 0; i < wiiu->shader_preset->passes; i++)
{ {
@ -1155,7 +1166,8 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
{ {
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].vs_ubos[j], j, wiiu_gfx_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, frame_count); wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars,
frame_count, frame_direction);
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]);
} }
@ -1166,7 +1178,8 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
{ {
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].ps_ubos[j], j, wiiu_gfx_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, frame_count); wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars,
frame_count, frame_direction);
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]);
} }