Vita: Fix alpha testing not being implemented

This commit is contained in:
UnknownShadow200 2023-08-25 18:02:28 +10:00
parent 24f0e980b1
commit 218fa25f89

View File

@ -8,7 +8,8 @@
/* Current format and size of vertices */ /* Current format and size of vertices */
static int gfx_stride, gfx_format = -1; static int gfx_stride, gfx_format = -1;
static cc_bool gfx_depthOnly, gfx_alphaBlending; static cc_bool gfx_depthOnly;
static cc_bool gfx_alphaTesting, gfx_alphaBlending;
static int frontBufferIndex, backBufferIndex; static int frontBufferIndex, backBufferIndex;
// Inspired from // Inspired from
// https://github.com/xerpi/gxmfun/blob/master/source/main.c // https://github.com/xerpi/gxmfun/blob/master/source/main.c
@ -69,6 +70,11 @@ static SceGxmProgram* gxm_colored_FP = (SceGxmProgram *)&colored_fs;
static SceGxmProgram* gxm_textured_VP = (SceGxmProgram *)&textured_vs; static SceGxmProgram* gxm_textured_VP = (SceGxmProgram *)&textured_vs;
static SceGxmProgram* gxm_textured_FP = (SceGxmProgram *)&textured_fs; static SceGxmProgram* gxm_textured_FP = (SceGxmProgram *)&textured_fs;
#include "../misc/vita/colored_alpha_fs.h"
static SceGxmProgram* gxm_colored_alpha_FP = (SceGxmProgram *)&colored_alpha_fs;
#include "../misc/vita/textured_alpha_fs.h"
static SceGxmProgram* gxm_textured_alpha_FP = (SceGxmProgram *)&textured_alpha_fs;
typedef struct CCVertexProgram { typedef struct CCVertexProgram {
SceGxmVertexProgram* programPatched; SceGxmVertexProgram* programPatched;
@ -218,7 +224,7 @@ static void VP_SwitchActive(void) {
/*########################################################################################################################* /*########################################################################################################################*
*----------------------------------------------------Fragment shaders-----------------------------------------------------* *----------------------------------------------------Fragment shaders-----------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static FragmentProgram FP_list[2 * 3]; static FragmentProgram FP_list[4 * 3];
static FragmentProgram* FP_Active; static FragmentProgram* FP_Active;
static void FP_SwitchActive(void) { static void FP_SwitchActive(void) {
@ -231,6 +237,8 @@ static void FP_SwitchActive(void) {
index += 1; index += 1;
} }
if (gfx_alphaTesting) index += 2 * 3;
FragmentProgram* FP = &FP_list[index]; FragmentProgram* FP = &FP_list[index];
if (FP == FP_Active) return; if (FP == FP_Active) return;
FP_Active = FP; FP_Active = FP;
@ -525,9 +533,11 @@ void Gfx_Create(void) {
AllocShaderPatcher(); AllocShaderPatcher();
AllocColouredVertexProgram(0); AllocColouredVertexProgram(0);
CreateFragmentPrograms(0, gxm_colored_FP, gxm_colored_VP); CreateFragmentPrograms(0, gxm_colored_FP, gxm_colored_VP);
CreateFragmentPrograms(6, gxm_colored_alpha_FP, gxm_colored_VP);
AllocTexturedVertexProgram(1); AllocTexturedVertexProgram(1);
CreateFragmentPrograms(3, gxm_textured_FP, gxm_textured_VP); CreateFragmentPrograms(3, gxm_textured_FP, gxm_textured_VP);
CreateFragmentPrograms(9, gxm_textured_alpha_FP, gxm_textured_VP);
Gfx_SetDepthTest(true); Gfx_SetDepthTest(true);
InitDefaultResources(); InitDefaultResources();
@ -828,8 +838,10 @@ void Gfx_SetFogMode(FogFunc func) {
// TODO // TODO
} }
void Gfx_SetAlphaTest(cc_bool enabled) { } void Gfx_SetAlphaTest(cc_bool enabled) {
// TODO gfx_alphaTesting = enabled;
FP_SwitchActive();
}
void Gfx_SetAlphaBlending(cc_bool enabled) { void Gfx_SetAlphaBlending(cc_bool enabled) {
gfx_alphaBlending = enabled; gfx_alphaBlending = enabled;
@ -979,6 +991,7 @@ void Gfx_Clear(void) {
clear_vertices[2] = (struct VertexColoured){ 1.0f, 1.0f, 1.0f, clear_color }; clear_vertices[2] = (struct VertexColoured){ 1.0f, 1.0f, 1.0f, clear_color };
clear_vertices[3] = (struct VertexColoured){-1.0f, 1.0f, 1.0f, clear_color }; clear_vertices[3] = (struct VertexColoured){-1.0f, 1.0f, 1.0f, clear_color };
Gfx_SetAlphaTest(false);
// can't use Gfx_SetDepthTest because that also affects depth writing // can't use Gfx_SetDepthTest because that also affects depth writing
depth_test = false; UpdateDepthFunction(); depth_test = false; UpdateDepthFunction();