mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-22 09:15:02 +00:00
(Vita) Changes for new tint shaders
This commit is contained in:
parent
0be7e96437
commit
8ad3cb14f8
@ -892,6 +892,7 @@ ifeq ($(HAVE_VITA2D), 1)
|
||||
$(DEPS_DIR)/libvita2d/shader/color_f_gxp.o \
|
||||
$(DEPS_DIR)/libvita2d/shader/texture_v_gxp.o \
|
||||
$(DEPS_DIR)/libvita2d/shader/texture_f_gxp.o \
|
||||
$(DEPS_DIR)/libvita2d/shader/texture_tint_v_gxp.o \
|
||||
$(DEPS_DIR)/libvita2d/shader/texture_tint_f_gxp.o
|
||||
|
||||
ifeq ($(HAVE_MENU_COMMON),1)
|
||||
|
3
deps/libvita2d/include/shared.h
vendored
3
deps/libvita2d/include/shared.h
vendored
@ -8,10 +8,11 @@ extern SceGxmVertexProgram *_vita2d_colorVertexProgram;
|
||||
extern SceGxmFragmentProgram *_vita2d_colorFragmentProgram;
|
||||
extern SceGxmVertexProgram *_vita2d_textureVertexProgram;
|
||||
extern SceGxmFragmentProgram *_vita2d_textureFragmentProgram;
|
||||
extern SceGxmVertexProgram *_vita2d_textureTintVertexProgram;
|
||||
extern SceGxmFragmentProgram *_vita2d_textureTintFragmentProgram;
|
||||
extern const SceGxmProgramParameter *_vita2d_colorWvpParam;
|
||||
extern const SceGxmProgramParameter *_vita2d_textureWvpParam;
|
||||
extern const SceGxmProgramParameter *_vita2d_textureTintColorParam;
|
||||
extern const SceGxmProgramParameter *_vita2d_textureTintWvpParam;
|
||||
|
||||
|
||||
#endif
|
||||
|
14
deps/libvita2d/include/vita2d.h
vendored
14
deps/libvita2d/include/vita2d.h
vendored
@ -31,6 +31,18 @@ typedef struct vita2d_texture_vertex {
|
||||
float v;
|
||||
} vita2d_texture_vertex;
|
||||
|
||||
typedef struct vita2d_texture_tint_vertex {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float u;
|
||||
float v;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float a;
|
||||
} vita2d_texture_tint_vertex;
|
||||
|
||||
typedef struct vita2d_texture {
|
||||
SceGxmTexture gxm_tex;
|
||||
SceUID data_UID;
|
||||
@ -120,7 +132,7 @@ void vita2d_draw_texture_part_scale_rotate(const vita2d_texture *texture, float
|
||||
void vita2d_draw_texture_tint(const vita2d_texture *texture, float x, float y, unsigned int color);
|
||||
void vita2d_draw_texture_tint_rotate(const vita2d_texture *texture, float x, float y, float rad, unsigned int color);
|
||||
void vita2d_draw_texture_tint_rotate_hotspot(const vita2d_texture *texture, float x, float y, float rad, float center_x, float center_y, unsigned int color);
|
||||
void vita2d_draw_texture_tint_scale(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, unsigned int color);
|
||||
void vita2d_draw_texture_tint_scale(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, const float *color);
|
||||
void vita2d_draw_texture_tint_part(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, unsigned int color);
|
||||
void vita2d_draw_texture_tint_part_scale(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale, unsigned int color);
|
||||
void vita2d_draw_texture_tint_scale_rotate_hotspot(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, float rad, float center_x, float center_y, unsigned int color);
|
||||
|
42
deps/libvita2d/shader/texture_tint_f_gxp.c
vendored
42
deps/libvita2d/shader/texture_tint_f_gxp.c
vendored
@ -1,24 +1,22 @@
|
||||
/* Generated by bin2c, do not edit manually */
|
||||
|
||||
/* Contents of file texture_tint_f.gxp */
|
||||
const long int texture_tint_f_gxp_size = 288;
|
||||
// Imported from file 'shader_f.gxp'
|
||||
const unsigned char texture_tint_f_gxp[288] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x1F, 0x01, 0x00, 0x00, 0xEA, 0xFC, 0xA0, 0xCB,
|
||||
0x79, 0x0C, 0xE6, 0xA5, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xF9, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xF8,
|
||||
0x02, 0x80, 0x99, 0xAF, 0xBC, 0x0D, 0xC0, 0x40, 0x3C, 0x00, 0x04, 0xCF, 0x84, 0x47, 0xA4, 0x08,
|
||||
0x00, 0xBC, 0x19, 0x20, 0x7E, 0x0D, 0x81, 0x40, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
|
||||
0x20, 0x00, 0x00, 0x00, 0x01, 0xE4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x1B, 0x00, 0x00, 0x00, 0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x75, 0x54, 0x69, 0x6E, 0x74, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x74, 0x65, 0x78, 0x00, 0x00
|
||||
0x47,0x58,0x50,0x00,0x01,0x05,0x10,0x03,0x20,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x05,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xc4,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
|
||||
0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x05,0x00,0x00,0x00,
|
||||
0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x74,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x00,0x00,0x00,0xc0,0x3c,0x03,0x00,
|
||||
0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x01,0x00,0x01,0x00,0x04,0x00,0x00,0x00,
|
||||
0x00,0xa9,0xd0,0x0e,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x44,0xfa,0x00,0x00,0x00,0x00,
|
||||
0x40,0x09,0x00,0xf8,0x02,0x80,0x99,0xaf,0xbc,0x0d,0xc0,0x40,0x06,0x82,0xb9,0xaf,
|
||||
0xbc,0x0d,0x80,0x40,0x7c,0x0f,0x04,0x00,0x86,0x47,0xa4,0x10,0x30,0x00,0x00,0x00,
|
||||
0x02,0x04,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x65,0x78,0x00
|
||||
};
|
||||
const unsigned int texture_tint_f_gxp_size = 288;
|
||||
|
28
deps/libvita2d/shader/texture_tint_v_gxp.c
vendored
Normal file
28
deps/libvita2d/shader/texture_tint_v_gxp.c
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Imported from file 'shader_v.gxp'
|
||||
const unsigned char texture_tint_v_gxp[384] = {
|
||||
0x47,0x58,0x50,0x00,0x01,0x05,0x10,0x03,0x7f,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
|
||||
0x0c,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x0b,0x00,0x00,0x00,
|
||||
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0xb0,0x00,0x00,0x00,0xc0,0x3c,0x03,0x00,
|
||||
0x00,0x00,0x00,0x00,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa4,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x94,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8c,0x00,0x00,0x00,
|
||||
0x01,0x00,0x00,0x00,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x0f,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x0a,
|
||||
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x07,0x44,0xfa,0x01,0x0e,0x01,0x01,0x02,0x00,0x10,0xfa,
|
||||
0x80,0x00,0x08,0x83,0x21,0x25,0x80,0x38,0x01,0x01,0x01,0x01,0x00,0x00,0x14,0xfa,
|
||||
0x02,0x80,0x81,0xaf,0x9c,0x0d,0xc0,0x40,0x0e,0x86,0xb9,0xff,0xbc,0x0d,0xc0,0x40,
|
||||
0x04,0x11,0x49,0xcf,0x80,0x8f,0xb1,0x18,0x02,0x11,0x45,0xcf,0x80,0x8f,0xb1,0x18,
|
||||
0x00,0x11,0x01,0xc0,0x81,0x81,0xb1,0x18,0x01,0xd1,0x42,0xc0,0x81,0x81,0xb1,0x18,
|
||||
0x00,0x00,0x20,0xa0,0x00,0x50,0x27,0xfb,0x0e,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
|
||||
0x40,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x3a,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
|
||||
0x34,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
|
||||
0x2b,0x00,0x00,0x00,0x01,0xe4,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x61,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x61,0x54,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x00,0x61,0x43,0x6f,0x6c,0x6f,0x72,0x00,0x77,0x76,0x70,0x00,0x00
|
||||
};
|
||||
const unsigned int texture_tint_v_gxp_size = 384;
|
66
deps/libvita2d/source/vita2d.c
vendored
66
deps/libvita2d/source/vita2d.c
vendored
@ -39,6 +39,7 @@ extern const SceGxmProgram color_v_gxp;
|
||||
extern const SceGxmProgram color_f_gxp;
|
||||
extern const SceGxmProgram texture_v_gxp;
|
||||
extern const SceGxmProgram texture_f_gxp;
|
||||
extern const SceGxmProgram texture_tint_v_gxp;
|
||||
extern const SceGxmProgram texture_tint_f_gxp;
|
||||
|
||||
/* Static variables */
|
||||
@ -51,6 +52,7 @@ static const SceGxmProgram *const colorVertexProgramGxp = &color_v_gxp;
|
||||
static const SceGxmProgram *const colorFragmentProgramGxp = &color_f_gxp;
|
||||
static const SceGxmProgram *const textureVertexProgramGxp = &texture_v_gxp;
|
||||
static const SceGxmProgram *const textureFragmentProgramGxp = &texture_f_gxp;
|
||||
static const SceGxmProgram *const textureTintVertexProgramGxp = &texture_tint_v_gxp;
|
||||
static const SceGxmProgram *const textureTintFragmentProgramGxp = &texture_tint_f_gxp;
|
||||
|
||||
static int vita2d_initialized = 0;
|
||||
@ -95,6 +97,7 @@ static SceGxmShaderPatcherId colorVertexProgramId;
|
||||
static SceGxmShaderPatcherId colorFragmentProgramId;
|
||||
static SceGxmShaderPatcherId textureVertexProgramId;
|
||||
static SceGxmShaderPatcherId textureFragmentProgramId;
|
||||
static SceGxmShaderPatcherId textureTintVertexProgramId;
|
||||
static SceGxmShaderPatcherId textureTintFragmentProgramId;
|
||||
|
||||
static SceUID patcherBufferUid;
|
||||
@ -113,11 +116,12 @@ SceGxmVertexProgram *_vita2d_colorVertexProgram = NULL;
|
||||
SceGxmFragmentProgram *_vita2d_colorFragmentProgram = NULL;
|
||||
SceGxmVertexProgram *_vita2d_textureVertexProgram = NULL;
|
||||
SceGxmFragmentProgram *_vita2d_textureFragmentProgram = NULL;
|
||||
SceGxmVertexProgram *_vita2d_textureTintVertexProgram = NULL;
|
||||
SceGxmFragmentProgram *_vita2d_textureTintFragmentProgram = NULL;
|
||||
const SceGxmProgramParameter *_vita2d_clearClearColorParam = NULL;
|
||||
const SceGxmProgramParameter *_vita2d_colorWvpParam = NULL;
|
||||
const SceGxmProgramParameter *_vita2d_textureWvpParam = NULL;
|
||||
const SceGxmProgramParameter *_vita2d_textureTintColorParam = NULL;
|
||||
const SceGxmProgramParameter *_vita2d_textureTintWvpParam = NULL;
|
||||
|
||||
typedef struct vita2d_fragment_programs {
|
||||
SceGxmFragmentProgram *color;
|
||||
@ -208,7 +212,7 @@ static void _vita2d_make_fragment_programs(vita2d_fragment_programs *out,
|
||||
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
||||
msaa,
|
||||
blend_info,
|
||||
textureVertexProgramGxp,
|
||||
textureTintVertexProgramGxp,
|
||||
&out->textureTint);
|
||||
|
||||
VITA2D_DEBUG("texture_tint sceGxmShaderPatcherCreateFragmentProgram(): 0x%08X\n", err);
|
||||
@ -442,6 +446,8 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
|
||||
VITA2D_DEBUG("texture_v sceGxmProgramCheck(): 0x%08X\n", err);
|
||||
err = sceGxmProgramCheck(textureFragmentProgramGxp);
|
||||
VITA2D_DEBUG("texture_f sceGxmProgramCheck(): 0x%08X\n", err);
|
||||
err = sceGxmProgramCheck(textureTintVertexProgramGxp);
|
||||
VITA2D_DEBUG("texture_v sceGxmProgramCheck(): 0x%08X\n", err);
|
||||
err = sceGxmProgramCheck(textureTintFragmentProgramGxp);
|
||||
VITA2D_DEBUG("texture_tint_f sceGxmProgramCheck(): 0x%08X\n", err);
|
||||
|
||||
@ -464,6 +470,9 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
|
||||
err = sceGxmShaderPatcherRegisterProgram(shaderPatcher, textureFragmentProgramGxp, &textureFragmentProgramId);
|
||||
VITA2D_DEBUG("texture_f sceGxmShaderPatcherRegisterProgram(): 0x%08X\n", err);
|
||||
|
||||
err = sceGxmShaderPatcherRegisterProgram(shaderPatcher, textureTintVertexProgramGxp, &textureTintVertexProgramId);
|
||||
VITA2D_DEBUG("texture_v sceGxmShaderPatcherRegisterProgram(): 0x%08X\n", err);
|
||||
|
||||
err = sceGxmShaderPatcherRegisterProgram(shaderPatcher, textureTintFragmentProgramGxp, &textureTintFragmentProgramId);
|
||||
VITA2D_DEBUG("texture_tint_f sceGxmShaderPatcherRegisterProgram(): 0x%08X\n", err);
|
||||
|
||||
@ -630,6 +639,52 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
|
||||
|
||||
VITA2D_DEBUG("texture sceGxmShaderPatcherCreateVertexProgram(): 0x%08X\n", err);
|
||||
|
||||
const SceGxmProgramParameter *paramTextureTintPositionAttribute = sceGxmProgramFindParameterByName(textureTintVertexProgramGxp, "aPosition");
|
||||
VITA2D_DEBUG("aPosition sceGxmProgramFindParameterByName(): %p\n", paramTextureTintPositionAttribute);
|
||||
|
||||
const SceGxmProgramParameter *paramTextureTintTexcoordAttribute = sceGxmProgramFindParameterByName(textureTintVertexProgramGxp, "aTexcoord");
|
||||
VITA2D_DEBUG("aTexcoord sceGxmProgramFindParameterByName(): %p\n", paramTextureTintTexcoordAttribute);
|
||||
|
||||
const SceGxmProgramParameter *paramTextureTintColorAttribute = sceGxmProgramFindParameterByName(textureTintVertexProgramGxp, "aColor");
|
||||
VITA2D_DEBUG("aColor sceGxmProgramFindParameterByName(): %p\n", paramTextureTintColorAttribute);
|
||||
|
||||
// create texture vertex format
|
||||
SceGxmVertexAttribute textureTintVertexAttributes[3];
|
||||
SceGxmVertexStream textureTintVertexStreams[1];
|
||||
/* x,y,z: 3 float 32 bits */
|
||||
textureTintVertexAttributes[0].streamIndex = 0;
|
||||
textureTintVertexAttributes[0].offset = 0;
|
||||
textureTintVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
textureTintVertexAttributes[0].componentCount = 3; // (x, y, z)
|
||||
textureTintVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTintPositionAttribute);
|
||||
/* u,v: 2 floats 32 bits */
|
||||
textureTintVertexAttributes[1].streamIndex = 0;
|
||||
textureTintVertexAttributes[1].offset = 12; // (x, y, z) * 4 = 12 bytes
|
||||
textureTintVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
textureTintVertexAttributes[1].componentCount = 2; // (u, v)
|
||||
textureTintVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTintTexcoordAttribute);
|
||||
/* r,g,b,a: 4 floats 32 bits */
|
||||
textureTintVertexAttributes[2].streamIndex = 0;
|
||||
textureTintVertexAttributes[2].offset = 20; // (u, v) * 4 = 8 bytes
|
||||
textureTintVertexAttributes[2].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
textureTintVertexAttributes[2].componentCount = 4; // (r, g, b, a)
|
||||
textureTintVertexAttributes[2].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTintColorAttribute);
|
||||
// 16 bit (short) indices
|
||||
textureTintVertexStreams[0].stride = sizeof(vita2d_texture_tint_vertex);
|
||||
textureTintVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
||||
|
||||
// create texture shaders
|
||||
err = sceGxmShaderPatcherCreateVertexProgram(
|
||||
shaderPatcher,
|
||||
textureTintVertexProgramId,
|
||||
textureTintVertexAttributes,
|
||||
3,
|
||||
textureTintVertexStreams,
|
||||
1,
|
||||
&_vita2d_textureTintVertexProgram);
|
||||
|
||||
VITA2D_DEBUG("texture sceGxmShaderPatcherCreateVertexProgram(): 0x%08X\n", err);
|
||||
|
||||
// Create variations of the fragment program based on blending mode
|
||||
_vita2d_make_fragment_programs(&_vita2d_fragmentPrograms.blend_mode_normal, &blend_info, msaa);
|
||||
_vita2d_make_fragment_programs(&_vita2d_fragmentPrograms.blend_mode_add, &blend_info_add, msaa);
|
||||
@ -647,8 +702,8 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
|
||||
_vita2d_textureWvpParam = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "wvp");
|
||||
VITA2D_DEBUG("texture wvp sceGxmProgramFindParameterByName(): %p\n", _vita2d_textureWvpParam);
|
||||
|
||||
_vita2d_textureTintColorParam = sceGxmProgramFindParameterByName(textureTintFragmentProgramGxp, "uTintColor");
|
||||
VITA2D_DEBUG("texture wvp sceGxmProgramFindParameterByName(): %p\n", _vita2d_textureWvpParam);
|
||||
_vita2d_textureTintWvpParam = sceGxmProgramFindParameterByName(textureTintVertexProgramGxp, "wvp");
|
||||
VITA2D_DEBUG("texture tint wvp sceGxmProgramFindParameterByName(): %p\n", _vita2d_textureTintWvpParam);
|
||||
|
||||
// Allocate memory for the memory pool
|
||||
pool_size = temp_pool_size;
|
||||
@ -743,7 +798,8 @@ int vita2d_fini()
|
||||
sceGxmShaderPatcherUnregisterProgram(shaderPatcher, colorVertexProgramId);
|
||||
sceGxmShaderPatcherUnregisterProgram(shaderPatcher, textureFragmentProgramId);
|
||||
sceGxmShaderPatcherUnregisterProgram(shaderPatcher, textureTintFragmentProgramId);
|
||||
sceGxmShaderPatcherUnregisterProgram(shaderPatcher, textureVertexProgramId);
|
||||
sceGxmShaderPatcherUnregisterProgram(shaderPatcher, textureTintVertexProgramId);
|
||||
sceGxmShaderPatcherUnregisterProgram(shaderPatcher, textureVertexProgramId);
|
||||
|
||||
sceGxmShaderPatcherDestroy(shaderPatcher);
|
||||
fragment_usse_free(patcherFragmentUsseUid);
|
||||
|
139
deps/libvita2d/source/vita2d_texture.c
vendored
139
deps/libvita2d/source/vita2d_texture.c
vendored
@ -271,7 +271,7 @@ static inline void set_texture_program()
|
||||
|
||||
static inline void set_texture_tint_program()
|
||||
{
|
||||
sceGxmSetVertexProgram(_vita2d_context, _vita2d_textureVertexProgram);
|
||||
sceGxmSetVertexProgram(_vita2d_context, _vita2d_textureTintVertexProgram);
|
||||
sceGxmSetFragmentProgram(_vita2d_context, _vita2d_textureTintFragmentProgram);
|
||||
}
|
||||
|
||||
@ -282,21 +282,11 @@ static inline void set_texture_wvp_uniform()
|
||||
sceGxmSetUniformDataF(vertex_wvp_buffer, _vita2d_textureWvpParam, 0, 16, _vita2d_ortho_matrix);
|
||||
}
|
||||
|
||||
static inline void set_texture_tint_color_uniform(unsigned int color)
|
||||
static inline void set_texture_tint_wvp_uniform()
|
||||
{
|
||||
void *texture_tint_color_buffer;
|
||||
sceGxmReserveFragmentDefaultUniformBuffer(_vita2d_context, &texture_tint_color_buffer);
|
||||
|
||||
float *tint_color = vita2d_pool_memalign(
|
||||
4 * sizeof(float), // RGBA
|
||||
sizeof(float));
|
||||
|
||||
tint_color[0] = ((color >> 8*0) & 0xFF)/255.0f;
|
||||
tint_color[1] = ((color >> 8*1) & 0xFF)/255.0f;
|
||||
tint_color[2] = ((color >> 8*2) & 0xFF)/255.0f;
|
||||
tint_color[3] = ((color >> 8*3) & 0xFF)/255.0f;
|
||||
|
||||
sceGxmSetUniformDataF(texture_tint_color_buffer, _vita2d_textureTintColorParam, 0, 4, tint_color);
|
||||
void *vertex_wvp_buffer;
|
||||
sceGxmReserveVertexDefaultUniformBuffer(_vita2d_context, &vertex_wvp_buffer);
|
||||
sceGxmSetUniformDataF(vertex_wvp_buffer, _vita2d_textureTintWvpParam, 0, 16, _vita2d_ortho_matrix);
|
||||
}
|
||||
|
||||
static inline void draw_texture_generic(const vita2d_texture *texture, float x, float y)
|
||||
@ -350,7 +340,6 @@ void vita2d_draw_texture_tint(const vita2d_texture *texture, float x, float y, u
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
draw_texture_generic(texture, x, y);
|
||||
}
|
||||
|
||||
@ -430,7 +419,6 @@ void vita2d_draw_texture_tint_rotate_hotspot(const vita2d_texture *texture, floa
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
draw_texture_rotate_hotspot_generic(texture, x, y, rad, center_x, center_y);
|
||||
}
|
||||
|
||||
@ -474,6 +462,54 @@ static inline void draw_texture_scale_generic(const vita2d_texture *texture, flo
|
||||
sceGxmDraw(_vita2d_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, vita2d_get_linear_indices(), 4);
|
||||
}
|
||||
|
||||
static inline void draw_texture_tint_scale_generic(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, const float *color)
|
||||
{
|
||||
vita2d_texture_tint_vertex *vertices = (vita2d_texture_tint_vertex *)vita2d_pool_memalign(
|
||||
4 * sizeof(vita2d_texture_tint_vertex), // 4 vertices
|
||||
sizeof(vita2d_texture_tint_vertex));
|
||||
|
||||
const float w = x_scale * vita2d_texture_get_width(texture);
|
||||
const float h = y_scale * vita2d_texture_get_height(texture);
|
||||
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = +0.5f;
|
||||
vertices[0].u = 0.0f;
|
||||
vertices[0].v = 0.0f;
|
||||
|
||||
vertices[1].x = x + w;
|
||||
vertices[1].y = y;
|
||||
vertices[1].z = +0.5f;
|
||||
vertices[1].u = 1.0f;
|
||||
vertices[1].v = 0.0f;
|
||||
|
||||
vertices[2].x = x;
|
||||
vertices[2].y = y + h;
|
||||
vertices[2].z = +0.5f;
|
||||
vertices[2].u = 0.0f;
|
||||
vertices[2].v = 1.0f;
|
||||
|
||||
vertices[3].x = x + w;
|
||||
vertices[3].y = y + h;
|
||||
vertices[3].z = +0.5f;
|
||||
vertices[3].u = 1.0f;
|
||||
vertices[3].v = 1.0f;
|
||||
|
||||
for(int n = 0; n < 4; n++){
|
||||
int k = (n + 2) % 4 ;
|
||||
vertices[n].r = color[4*k+0];
|
||||
vertices[n].g = color[4*k+1];
|
||||
vertices[n].b = color[4*k+2];
|
||||
vertices[n].a = color[4*k+3];
|
||||
}
|
||||
|
||||
// Set the texture to the TEXUNIT0
|
||||
sceGxmSetFragmentTexture(_vita2d_context, 0, &texture->gxm_tex);
|
||||
|
||||
sceGxmSetVertexStream(_vita2d_context, 0, vertices);
|
||||
sceGxmDraw(_vita2d_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, vita2d_get_linear_indices(), 4);
|
||||
}
|
||||
|
||||
void vita2d_draw_texture_scale(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale)
|
||||
{
|
||||
set_texture_program();
|
||||
@ -481,12 +517,11 @@ void vita2d_draw_texture_scale(const vita2d_texture *texture, float x, float y,
|
||||
draw_texture_scale_generic(texture, x, y, x_scale, y_scale);
|
||||
}
|
||||
|
||||
void vita2d_draw_texture_tint_scale(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, unsigned int color)
|
||||
void vita2d_draw_texture_tint_scale(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, const float *color)
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
draw_texture_scale_generic(texture, x, y, x_scale, y_scale);
|
||||
set_texture_tint_wvp_uniform();
|
||||
draw_texture_tint_scale_generic(texture, x, y, x_scale, y_scale, color);
|
||||
}
|
||||
|
||||
|
||||
@ -546,7 +581,6 @@ void vita2d_draw_texture_tint_part(const vita2d_texture *texture, float x, float
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
draw_texture_part_generic(texture, x, y, tex_x, tex_y, tex_w, tex_h);
|
||||
}
|
||||
|
||||
@ -598,6 +632,61 @@ static inline void draw_texture_part_scale_generic(const vita2d_texture *texture
|
||||
sceGxmDraw(_vita2d_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, vita2d_get_linear_indices(), 4);
|
||||
}
|
||||
|
||||
static inline void draw_texture_tint_part_scale_generic(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale, unsigned int color)
|
||||
{
|
||||
vita2d_texture_tint_vertex *vertices = (vita2d_texture_tint_vertex *)vita2d_pool_memalign(
|
||||
4 * sizeof(vita2d_texture_tint_vertex), // 4 vertices
|
||||
sizeof(vita2d_texture_tint_vertex));
|
||||
|
||||
const float w = vita2d_texture_get_width(texture);
|
||||
const float h = vita2d_texture_get_height(texture);
|
||||
|
||||
const float u0 = tex_x/w;
|
||||
const float v0 = tex_y/h;
|
||||
const float u1 = (tex_x+tex_w)/w;
|
||||
const float v1 = (tex_y+tex_h)/h;
|
||||
|
||||
tex_w *= x_scale;
|
||||
tex_h *= y_scale;
|
||||
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = +0.5f;
|
||||
vertices[0].u = u0;
|
||||
vertices[0].v = v0;
|
||||
|
||||
vertices[1].x = x + tex_w;
|
||||
vertices[1].y = y;
|
||||
vertices[1].z = +0.5f;
|
||||
vertices[1].u = u1;
|
||||
vertices[1].v = v0;
|
||||
|
||||
vertices[2].x = x;
|
||||
vertices[2].y = y + tex_h;
|
||||
vertices[2].z = +0.5f;
|
||||
vertices[2].u = u0;
|
||||
vertices[2].v = v1;
|
||||
|
||||
vertices[3].x = x + tex_w;
|
||||
vertices[3].y = y + tex_h;
|
||||
vertices[3].z = +0.5f;
|
||||
vertices[3].u = u1;
|
||||
vertices[3].v = v1;
|
||||
|
||||
for(int n = 0; n < 4; n++){
|
||||
vertices[n].r = ((color >> 8*0) & 0xFF)/255.0f;
|
||||
vertices[n].g = ((color >> 8*1) & 0xFF)/255.0f;
|
||||
vertices[n].b = ((color >> 8*2) & 0xFF)/255.0f;
|
||||
vertices[n].a = ((color >> 8*3) & 0xFF)/255.0f;
|
||||
}
|
||||
|
||||
// Set the texture to the TEXUNIT0
|
||||
sceGxmSetFragmentTexture(_vita2d_context, 0, &texture->gxm_tex);
|
||||
|
||||
sceGxmSetVertexStream(_vita2d_context, 0, vertices);
|
||||
sceGxmDraw(_vita2d_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, vita2d_get_linear_indices(), 4);
|
||||
}
|
||||
|
||||
void vita2d_draw_texture_part_scale(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale)
|
||||
{
|
||||
set_texture_program();
|
||||
@ -609,8 +698,7 @@ void vita2d_draw_texture_tint_part_scale(const vita2d_texture *texture, float x,
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
draw_texture_part_scale_generic(texture, x, y, tex_x, tex_y, tex_w, tex_h, x_scale, y_scale);
|
||||
draw_texture_tint_part_scale_generic(texture, x, y, tex_x, tex_y, tex_w, tex_h, x_scale, y_scale, color);
|
||||
}
|
||||
|
||||
static inline void draw_texture_scale_rotate_hotspot_generic(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, float rad, float center_x, float center_y)
|
||||
@ -684,7 +772,6 @@ void vita2d_draw_texture_tint_scale_rotate_hotspot(const vita2d_texture *texture
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
draw_texture_scale_rotate_hotspot_generic(texture, x, y, x_scale, y_scale,
|
||||
rad, center_x, center_y);
|
||||
}
|
||||
@ -769,7 +856,6 @@ void vita2d_draw_texture_part_tint_scale_rotate(const vita2d_texture *texture, f
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
draw_texture_part_scale_rotate_generic(texture, x, y,
|
||||
tex_x, tex_y, tex_w, tex_h, x_scale, y_scale, rad);
|
||||
}
|
||||
@ -778,7 +864,6 @@ void vita2d_draw_array_textured(const vita2d_texture *texture, SceGxmPrimitiveTy
|
||||
{
|
||||
set_texture_tint_program();
|
||||
set_texture_wvp_uniform();
|
||||
set_texture_tint_color_uniform(color);
|
||||
|
||||
sceGxmSetBackPolygonMode(_vita2d_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user