mirror of
https://github.com/shadps4-emu/ext-SDL.git
synced 2024-12-20 09:48:16 +00:00
Implement blend modes
This commit is contained in:
parent
075f9016fa
commit
fb1a205e70
@ -379,6 +379,42 @@ PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||||
|
{
|
||||||
|
#define A_COLOR_SOURCE 0
|
||||||
|
#define A_COLOR_DEST 1
|
||||||
|
#define A_COLOR_NULL 2
|
||||||
|
#define A_ALPHA_SOURCE 0
|
||||||
|
#define A_ALPHA_DEST 1
|
||||||
|
#define A_ALPHA_FIX 2
|
||||||
|
|
||||||
|
switch (blendMode)
|
||||||
|
{
|
||||||
|
case SDL_BLENDMODE_NONE: {
|
||||||
|
data->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_BLENDMODE_BLEND:{
|
||||||
|
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_DEST, A_ALPHA_SOURCE, A_COLOR_DEST, 0), 0);
|
||||||
|
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_BLENDMODE_ADD: {
|
||||||
|
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0);
|
||||||
|
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_BLENDMODE_MUL:
|
||||||
|
case SDL_BLENDMODE_MOD: {
|
||||||
|
/* We don't fully support MOD and MUL, however this is the best we can do */
|
||||||
|
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_SOURCE, A_COLOR_SOURCE, 0x80), 0);
|
||||||
|
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||||
{
|
{
|
||||||
@ -391,6 +427,8 @@ PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cm
|
|||||||
|
|
||||||
const size_t count = cmd->data.draw.count;
|
const size_t count = cmd->data.draw.count;
|
||||||
|
|
||||||
|
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||||
|
|
||||||
if (cmd->data.draw.texture) {
|
if (cmd->data.draw.texture) {
|
||||||
const texture_vertex *verts = (texture_vertex *) (vertices + cmd->data.draw.first);
|
const texture_vertex *verts = (texture_vertex *) (vertices + cmd->data.draw.first);
|
||||||
GSTEXTURE *ps2_tex = (GSTEXTURE *) cmd->data.draw.texture->driverdata;
|
GSTEXTURE *ps2_tex = (GSTEXTURE *) cmd->data.draw.texture->driverdata;
|
||||||
@ -476,6 +514,8 @@ PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd)
|
|||||||
|
|
||||||
const color_vertex *verts = (color_vertex *) (vertices + cmd->data.draw.first);
|
const color_vertex *verts = (color_vertex *) (vertices + cmd->data.draw.first);
|
||||||
|
|
||||||
|
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||||
|
|
||||||
for (i = 0; i < count-1; i++, verts++) {
|
for (i = 0; i < count-1; i++, verts++) {
|
||||||
x1 = verts[i*2].x;
|
x1 = verts[i*2].x;
|
||||||
y1 = verts[i*2].y;
|
y1 = verts[i*2].y;
|
||||||
@ -505,6 +545,8 @@ PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd
|
|||||||
const uint8_t ColorB = cmd->data.draw.b >> 1;
|
const uint8_t ColorB = cmd->data.draw.b >> 1;
|
||||||
const uint8_t ColorA = cmd->data.draw.a >> 1;
|
const uint8_t ColorA = cmd->data.draw.a >> 1;
|
||||||
|
|
||||||
|
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||||
|
|
||||||
color = GS_SETREG_RGBAQ(ColorR, ColorG, ColorB, ColorA, 0x00);
|
color = GS_SETREG_RGBAQ(ColorR, ColorG, ColorB, ColorA, 0x00);
|
||||||
|
|
||||||
const clear_vertex *verts = (clear_vertex *) (vertices + cmd->data.draw.first);
|
const clear_vertex *verts = (clear_vertex *) (vertices + cmd->data.draw.first);
|
||||||
|
Loading…
Reference in New Issue
Block a user