mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Merge pull request #8311 from fjtrujy/feature/ImprovementPalette
[PS2] Improvement the use of the palette
This commit is contained in:
commit
45287628d4
@ -193,7 +193,6 @@ static const char *getMountParams(const char *command, char *BlockDevice)
|
|||||||
|
|
||||||
static void create_path_names(void)
|
static void create_path_names(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], g_defaults.dirs[DEFAULT_DIR_PORT],
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], g_defaults.dirs[DEFAULT_DIR_PORT],
|
||||||
"CORES", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
"CORES", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
||||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_PORT],
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_PORT],
|
||||||
|
@ -134,15 +134,17 @@ static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, bool force_aspect)
|
static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, bool force_aspect, struct retro_hw_ps2_insets padding)
|
||||||
{
|
{
|
||||||
float x1, y1, x2, y2;
|
float x1, y1, x2, y2;
|
||||||
|
float visible_width = texture->Width - padding.left - padding.right;
|
||||||
|
float visible_height = texture->Height - padding.top - padding.bottom;
|
||||||
if (force_aspect) {
|
if (force_aspect) {
|
||||||
float width_proportion = (float)gsGlobal->Width / (float)texture->Width;
|
float width_proportion = (float)gsGlobal->Width / (float)visible_width;
|
||||||
float height_proportion = (float)gsGlobal->Height / (float)texture->Height;
|
float height_proportion = (float)gsGlobal->Height / (float)visible_height;
|
||||||
float delta = MIN(width_proportion, height_proportion);
|
float delta = MIN(width_proportion, height_proportion);
|
||||||
float newWidth = texture->Width * delta;
|
float newWidth = visible_width * delta;
|
||||||
float newHeight = texture->Height * delta;
|
float newHeight = visible_height * delta;
|
||||||
|
|
||||||
x1 = (gsGlobal->Width - newWidth) / 2.0f;
|
x1 = (gsGlobal->Width - newWidth) / 2.0f;
|
||||||
y1 = (gsGlobal->Height - newHeight) / 2.0f;
|
y1 = (gsGlobal->Height - newHeight) / 2.0f;
|
||||||
@ -159,12 +161,12 @@ static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition,
|
|||||||
gsKit_prim_sprite_texture( gsGlobal, texture,
|
gsKit_prim_sprite_texture( gsGlobal, texture,
|
||||||
x1, //X1
|
x1, //X1
|
||||||
y1, // Y1
|
y1, // Y1
|
||||||
0.0f, // U1
|
padding.left, // U1
|
||||||
0.0f, // V1
|
padding.top, // V1
|
||||||
x2, // X2
|
x2, // X2
|
||||||
y2, // Y2
|
y2, // Y2
|
||||||
texture->Width, // U2
|
texture->Width - padding.right, // U2
|
||||||
texture->Height, // V2
|
texture->Height - padding.bottom, // V2
|
||||||
zPosition,
|
zPosition,
|
||||||
GS_TEXT);
|
GS_TEXT);
|
||||||
}
|
}
|
||||||
@ -194,6 +196,27 @@ static void refreshScreen(ps2_video_t *ps2)
|
|||||||
|
|
||||||
ps2->clearVRAM = false;
|
ps2->clearVRAM = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, bool sendPalette)
|
||||||
|
{
|
||||||
|
gsKit_setup_tbw(Texture);
|
||||||
|
|
||||||
|
if (Texture->PSM == GS_PSM_T8) {
|
||||||
|
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE);
|
||||||
|
if (sendPalette) {
|
||||||
|
gsKit_texture_send(Texture->Clut, 16, 16, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (Texture->PSM == GS_PSM_T4) {
|
||||||
|
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE);
|
||||||
|
if (sendPalette) {
|
||||||
|
gsKit_texture_send(Texture->Clut, 8, 2, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void *ps2_gfx_init(const video_info_t *video,
|
static void *ps2_gfx_init(const video_info_t *video,
|
||||||
const input_driver_t **input, void **input_data)
|
const input_driver_t **input, void **input_data)
|
||||||
{
|
{
|
||||||
@ -245,14 +268,24 @@ static bool ps2_gfx_frame(void *data, const void *frame,
|
|||||||
clearVRAMIfNeeded(ps2, frame, width, height);
|
clearVRAMIfNeeded(ps2, frame, width, height);
|
||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
|
bool sendPalette = false;
|
||||||
|
struct retro_hw_ps2_insets padding = empty_ps2_insets;
|
||||||
if (frame != RETRO_HW_FRAME_BUFFER_VALID){ /* Checking if the transfer is done in the core */
|
if (frame != RETRO_HW_FRAME_BUFFER_VALID){ /* Checking if the transfer is done in the core */
|
||||||
transfer_texture(ps2->coreTexture, frame, width, height, ps2->PSM, ps2->core_filter, 1);
|
transfer_texture(ps2->coreTexture, frame, width, height, ps2->PSM, ps2->core_filter, 1);
|
||||||
|
} else {
|
||||||
|
sendPalette = ps2->iface.updatedPalette;
|
||||||
|
ps2->iface.updatedPalette = false;
|
||||||
|
padding = ps2->iface.padding;
|
||||||
|
if (ps2->iface.clearTexture) {
|
||||||
|
gsKit_clear(ps2->gsGlobal, GS_BLACK);
|
||||||
|
ps2->iface.clearTexture = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(ps2->clearVRAM) {
|
if(ps2->clearVRAM) {
|
||||||
vram_alloc(ps2->gsGlobal, ps2->coreTexture);
|
vram_alloc(ps2->gsGlobal, ps2->coreTexture);
|
||||||
}
|
}
|
||||||
gsKit_texture_upload(ps2->gsGlobal, ps2->coreTexture);
|
ps2_texture_upload(ps2->gsGlobal, ps2->coreTexture, sendPalette);
|
||||||
prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect);
|
prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps2->menuVisible) {
|
if (ps2->menuVisible) {
|
||||||
@ -262,7 +295,7 @@ static bool ps2_gfx_frame(void *data, const void *frame,
|
|||||||
vram_alloc(ps2->gsGlobal, ps2->menuTexture);
|
vram_alloc(ps2->gsGlobal, ps2->menuTexture);
|
||||||
}
|
}
|
||||||
gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture);
|
gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture);
|
||||||
prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, ps2->fullscreen);
|
prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, ps2->fullscreen, empty_ps2_insets);
|
||||||
}
|
}
|
||||||
} else if (video_info->statistics_show) {
|
} else if (video_info->statistics_show) {
|
||||||
struct font_params *osd_params = (struct font_params*)
|
struct font_params *osd_params = (struct font_params*)
|
||||||
@ -419,6 +452,8 @@ static bool ps2_get_hw_render_interface(void* data,
|
|||||||
{
|
{
|
||||||
ps2_video_t* ps2 = (ps2_video_t*)data;
|
ps2_video_t* ps2 = (ps2_video_t*)data;
|
||||||
ps2->iface.clearTexture = ps2->clearVRAM;
|
ps2->iface.clearTexture = ps2->clearVRAM;
|
||||||
|
ps2->iface.updatedPalette = true;
|
||||||
|
ps2->iface.padding = empty_ps2_insets;
|
||||||
*iface = (const struct retro_hw_render_interface*)&ps2->iface;
|
*iface = (const struct retro_hw_render_interface*)&ps2->iface;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,16 @@
|
|||||||
|
|
||||||
#define RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION 1
|
#define RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION 1
|
||||||
|
|
||||||
|
struct retro_hw_ps2_insets
|
||||||
|
{
|
||||||
|
float top;
|
||||||
|
float left;
|
||||||
|
float bottom;
|
||||||
|
float right;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define empty_ps2_insets (struct retro_hw_ps2_insets){0.f, 0.f, 0.f, 0.f}
|
||||||
|
|
||||||
struct retro_hw_render_interface_gskit_ps2
|
struct retro_hw_render_interface_gskit_ps2
|
||||||
{
|
{
|
||||||
/* Must be set to RETRO_HW_RENDER_INTERFACE_GSKIT_PS2. */
|
/* Must be set to RETRO_HW_RENDER_INTERFACE_GSKIT_PS2. */
|
||||||
@ -48,6 +58,8 @@ struct retro_hw_render_interface_gskit_ps2
|
|||||||
*/
|
*/
|
||||||
GSTEXTURE *coreTexture;
|
GSTEXTURE *coreTexture;
|
||||||
bool clearTexture;
|
bool clearTexture;
|
||||||
|
bool updatedPalette;
|
||||||
|
struct retro_hw_ps2_insets padding;
|
||||||
};
|
};
|
||||||
typedef struct retro_hw_render_interface_gskit_ps2 RETRO_HW_RENDER_INTEFACE_GSKIT_PS2;
|
typedef struct retro_hw_render_interface_gskit_ps2 RETRO_HW_RENDER_INTEFACE_GSKIT_PS2;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#define floor(x) ((double)floorf((float)x))
|
#define floor(x) ((double)floorf((float)x))
|
||||||
#define sqrt(x) ((double)sqrtf((float)x))
|
#define sqrt(x) ((double)sqrtf((float)x))
|
||||||
#define fabs(x) ((double)fabsf((float)(x)))
|
#define fabs(x) ((double)fabsf((float)(x)))
|
||||||
|
#define round(x) ((double)roundf((float)(x)))
|
||||||
|
|
||||||
#define fmaxf(a, b) (((a) > (b)) ? (a) : (b))
|
#define fmaxf(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
#define fminf(a, b) (((a) < (b)) ? (a) : (b))
|
#define fminf(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user