From 758b3ad2cccd43ccb5aa0dec2ad4d2f9bae7b2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Thu, 12 Dec 2019 19:16:28 +0100 Subject: [PATCH 1/9] (VITA) Make VITA2D the default driver --- configuration.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration.c b/configuration.c index 49c7e3bc37..7249a4c035 100644 --- a/configuration.c +++ b/configuration.c @@ -319,6 +319,8 @@ enum midi_driver_enum #if defined(HAVE_METAL) static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_METAL; +#elif defined(HAVE_VITA2D) +static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_VITA2D; #elif defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__) static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_GL; #elif defined(HAVE_OPENGL_CORE) @@ -345,8 +347,6 @@ static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D9; static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D8; #elif defined(HAVE_VG) static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_VG; -#elif defined(HAVE_VITA2D) -static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_VITA2D; #elif defined(PSP) static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_PSP1; #elif defined(PS2) From eef7611cf1fce8e2b50cd44da2710f2074ddd2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Fri, 13 Dec 2019 11:26:15 +0100 Subject: [PATCH 2/9] Fix for duplicated error symbol --- deps/vitaGL/source/custom_shaders.c | 10 ++-- deps/vitaGL/source/framebuffers.c | 12 ++--- deps/vitaGL/source/get_info.c | 14 ++--- deps/vitaGL/source/gxm.c | 2 +- deps/vitaGL/source/legacy.c | 18 +++---- deps/vitaGL/source/matrices.c | 24 ++++----- deps/vitaGL/source/misc.c | 32 ++++++------ deps/vitaGL/source/shared.h | 2 +- deps/vitaGL/source/tests.c | 42 +++++++-------- deps/vitaGL/source/textures.c | 64 +++++++++++------------ deps/vitaGL/source/vitaGL.c | 80 ++++++++++++++--------------- 11 files changed, 150 insertions(+), 150 deletions(-) diff --git a/deps/vitaGL/source/custom_shaders.c b/deps/vitaGL/source/custom_shaders.c index 44f043d400..3590e0139c 100644 --- a/deps/vitaGL/source/custom_shaders.c +++ b/deps/vitaGL/source/custom_shaders.c @@ -127,7 +127,7 @@ GLuint glCreateShader(GLenum shaderType) { shaders[res - 1].type = GL_VERTEX_SHADER; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } shaders[res - 1].valid = GL_TRUE; @@ -176,7 +176,7 @@ void glAttachShader(GLuint prog, GLuint shad) { break; } } else - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; } GLuint glCreateProgram(void) { @@ -365,7 +365,7 @@ void vglBindAttribLocation(GLuint prog, GLuint index, const GLchar *name, const bpe = sizeof(uint8_t); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } @@ -383,7 +383,7 @@ void vglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean nor #ifndef SKIP_ERROR_HANDLING // Error handling if (stride < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -398,7 +398,7 @@ void vglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean nor bpe = sizeof(GLshort); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } diff --git a/deps/vitaGL/source/framebuffers.c b/deps/vitaGL/source/framebuffers.c index 175ee94ab8..3b97d07274 100644 --- a/deps/vitaGL/source/framebuffers.c +++ b/deps/vitaGL/source/framebuffers.c @@ -32,7 +32,7 @@ uint32_t get_color_from_texture(uint32_t type) { res = SCE_GXM_COLOR_FORMAT_U8_A; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } return res; @@ -48,7 +48,7 @@ void glGenFramebuffers(GLsizei n, GLuint *ids) { int i = 0, j = 0; #ifndef SKIP_ERROR_HANDLING if (n < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -67,7 +67,7 @@ void glGenFramebuffers(GLsizei n, GLuint *ids) { void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) { #ifndef SKIP_ERROR_HANDLING if (n < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -99,7 +99,7 @@ void glBindFramebuffer(GLenum target, GLuint fb) { active_write_fb = active_read_fb = (framebuffer *)fb; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -116,7 +116,7 @@ void glFramebufferTexture(GLenum target, GLenum attachment, GLuint tex_id, GLint fb = active_read_fb; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } @@ -160,7 +160,7 @@ void glFramebufferTexture(GLenum target, GLenum attachment, GLuint tex_id, GLint sceGxmCreateRenderTarget(&renderTargetParams, &fb->target); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } diff --git a/deps/vitaGL/source/get_info.c b/deps/vitaGL/source/get_info.c index 98f9f8c991..612a0e7daa 100644 --- a/deps/vitaGL/source/get_info.c +++ b/deps/vitaGL/source/get_info.c @@ -32,7 +32,7 @@ const GLubyte *glGetString(GLenum name) { return extensions; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; return NULL; break; } @@ -62,7 +62,7 @@ void glGetBooleanv(GLenum pname, GLboolean *params) { *params = GL_FALSE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -91,7 +91,7 @@ void glGetFloatv(GLenum pname, GLfloat *data) { *data = GENERIC_STACK_DEPTH; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -124,7 +124,7 @@ void glGetIntegerv(GLenum pname, GLint *data) { data[3] = gl_viewport.h; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -157,14 +157,14 @@ GLboolean glIsEnabled(GLenum cap) { ret = pol_offset_point; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } return ret; } GLenum glGetError(void) { - GLenum ret = error; - error = GL_NO_ERROR; + GLenum ret = _vitagl_error; + _vitagl_error = GL_NO_ERROR; return ret; } diff --git a/deps/vitaGL/source/gxm.c b/deps/vitaGL/source/gxm.c index 7aca0aaa60..64659345d5 100644 --- a/deps/vitaGL/source/gxm.c +++ b/deps/vitaGL/source/gxm.c @@ -27,7 +27,7 @@ static void *gxm_stencil_surface_addr; // Stencil surface memblock starting addr static SceGxmDepthStencilSurface gxm_depth_stencil_surface; // Depth/Stencil surfaces setup for sceGxm SceGxmContext *gxm_context; // sceGxm context instance -GLenum error = GL_NO_ERROR; // Error returned by glGetError +GLenum _vitagl_error = GL_NO_ERROR; // Error returned by glGetError SceGxmShaderPatcher *gxm_shader_patcher; // sceGxmShaderPatcher shader patcher instance matrix4x4 mvp_matrix; // ModelViewProjection Matrix diff --git a/deps/vitaGL/source/legacy.c b/deps/vitaGL/source/legacy.c index 2123a4a6c6..6b01e79699 100644 --- a/deps/vitaGL/source/legacy.c +++ b/deps/vitaGL/source/legacy.c @@ -69,7 +69,7 @@ void glVertex3f(GLfloat x, GLfloat y, GLfloat z) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase != MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -100,7 +100,7 @@ void glVertex3fv(const GLfloat *v) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase != MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -191,7 +191,7 @@ void glTexCoord2fv(GLfloat *f) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase != MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -214,7 +214,7 @@ void glTexCoord2f(GLfloat s, GLfloat t) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase != MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -237,7 +237,7 @@ void glTexCoord2i(GLint s, GLint t) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase != MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -260,7 +260,7 @@ void glArrayElement(GLint i) { #ifndef SKIP_ERROR_HANDLING // Error handling if (i < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -340,7 +340,7 @@ void glBegin(GLenum mode) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -377,7 +377,7 @@ void glBegin(GLenum mode) { np = 4; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } @@ -393,7 +393,7 @@ void glEnd(void) { // Error handling if (phase != MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif diff --git a/deps/vitaGL/source/matrices.c b/deps/vitaGL/source/matrices.c index d96516b619..618e48d8dc 100644 --- a/deps/vitaGL/source/matrices.c +++ b/deps/vitaGL/source/matrices.c @@ -28,7 +28,7 @@ void glMatrixMode(GLenum mode) { matrix = &projection_matrix; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -37,10 +37,10 @@ void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdou #ifndef SKIP_ERROR_HANDLING // Error handling if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } else if ((left == right) || (bottom == top) || (nearVal == farVal)) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -54,10 +54,10 @@ void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLd #ifndef SKIP_ERROR_HANDLING // Error handling if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } else if ((left == right) || (bottom == top) || (nearVal < 0) || (farVal < 0)) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -130,7 +130,7 @@ void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -153,7 +153,7 @@ void glPushMatrix(void) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -162,7 +162,7 @@ void glPushMatrix(void) { #ifndef SKIP_ERROR_HANDLING // Error handling if (modelview_stack_counter >= MODELVIEW_STACK_DEPTH) { - error = GL_STACK_OVERFLOW; + _vitagl_error = GL_STACK_OVERFLOW; } else #endif // Copying current matrix into the matrix stack and increasing stack counter @@ -172,7 +172,7 @@ void glPushMatrix(void) { #ifndef SKIP_ERROR_HANDLING // Error handling if (projection_stack_counter >= GENERIC_STACK_DEPTH) { - error = GL_STACK_OVERFLOW; + _vitagl_error = GL_STACK_OVERFLOW; } else #endif // Copying current matrix into the matrix stack and increasing stack counter @@ -184,7 +184,7 @@ void glPopMatrix(void) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -193,7 +193,7 @@ void glPopMatrix(void) { #ifndef SKIP_ERROR_HANDLING // Error handling if (modelview_stack_counter == 0) - error = GL_STACK_UNDERFLOW; + _vitagl_error = GL_STACK_UNDERFLOW; else #endif // Copying last matrix on stack into current matrix and decreasing stack counter @@ -203,7 +203,7 @@ void glPopMatrix(void) { #ifndef SKIP_ERROR_HANDLING // Error handling if (projection_stack_counter == 0) - error = GL_STACK_UNDERFLOW; + _vitagl_error = GL_STACK_UNDERFLOW; else #endif // Copying last matrix on stack into current matrix and decreasing stack counter diff --git a/deps/vitaGL/source/misc.c b/deps/vitaGL/source/misc.c index 6effcf2a66..aa1c89dd93 100644 --- a/deps/vitaGL/source/misc.c +++ b/deps/vitaGL/source/misc.c @@ -101,7 +101,7 @@ void glPolygonMode(GLenum face, GLenum mode) { new_mode = SCE_GXM_POLYGON_MODE_TRIANGLE_FILL; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } switch (face) { @@ -122,7 +122,7 @@ void glPolygonMode(GLenum face, GLenum mode) { sceGxmSetBackPolygonMode(gxm_context, new_mode); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; return; } update_polygon_offset(); @@ -149,7 +149,7 @@ void glFrontFace(GLenum mode) { void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) { #ifndef SKIP_ERROR_HANDLING if ((width < 0) || (height < 0)) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -182,7 +182,7 @@ void glDepthRangef(GLfloat nearVal, GLfloat farVal) { void glEnable(GLenum cap) { #ifndef SKIP_ERROR_HANDLING if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -235,7 +235,7 @@ void glEnable(GLenum cap) { clip_plane0 = GL_TRUE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -243,7 +243,7 @@ void glEnable(GLenum cap) { void glDisable(GLenum cap) { #ifndef SKIP_ERROR_HANDLING if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -296,7 +296,7 @@ void glDisable(GLenum cap) { clip_plane0 = GL_FALSE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -393,7 +393,7 @@ void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -411,12 +411,12 @@ void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -425,7 +425,7 @@ void glLineWidth(GLfloat width) { #ifndef SKIP_ERROR_HANDLING // Error handling if (width <= 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -439,7 +439,7 @@ void glPointSize(GLfloat size) { #ifndef SKIP_ERROR_HANDLING // Error handling if (size <= 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -465,7 +465,7 @@ void glFogf(GLenum pname, GLfloat param) { fog_far = param; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -489,7 +489,7 @@ void glFogfv(GLenum pname, const GLfloat *params) { memcpy(&fog_color.r, params, sizeof(vector4f)); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -510,7 +510,7 @@ void glFogi(GLenum pname, const GLint param) { fog_far = param; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -530,7 +530,7 @@ void glClipPlane(GLenum plane, const GLdouble *equation) { memcpy(&clip_plane0_eq.x, &temp.x, sizeof(vector4f)); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } diff --git a/deps/vitaGL/source/shared.h b/deps/vitaGL/source/shared.h index ce799338f1..4f9453b70c 100644 --- a/deps/vitaGL/source/shared.h +++ b/deps/vitaGL/source/shared.h @@ -97,7 +97,7 @@ extern float y_scale; extern float z_scale; extern SceGxmContext *gxm_context; // sceGxm context instance -extern GLenum error; // Error returned by glGetError +extern GLenum _vitagl_error; // Error returned by glGetError extern SceGxmShaderPatcher *gxm_shader_patcher; // sceGxmShaderPatcher shader patcher instance matrix4x4 mvp_matrix; // ModelViewProjection Matrix diff --git a/deps/vitaGL/source/tests.c b/deps/vitaGL/source/tests.c index 104796a2c2..d1afbef677 100644 --- a/deps/vitaGL/source/tests.c +++ b/deps/vitaGL/source/tests.c @@ -282,7 +282,7 @@ void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { #ifndef SKIP_ERROR_HANDLING // Error handling if ((width < 0) || (height < 0)) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -340,7 +340,7 @@ void glDepthMask(GLboolean flag) { #ifndef SKIP_ERROR_HANDLING // Error handling if (phase == MODEL_CREATION) { - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; return; } #endif @@ -362,36 +362,36 @@ void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass switch (face) { case GL_FRONT: if (!change_stencil_config(&stencil_fail_front, sfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_fail_front, dpfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_pass_front, dppass)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; case GL_BACK: if (!change_stencil_config(&stencil_fail_back, sfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_fail_back, dpfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_pass_front, dppass)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; case GL_FRONT_AND_BACK: if (!change_stencil_config(&stencil_fail_front, sfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&stencil_fail_back, sfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_fail_front, dpfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_fail_back, dpfail)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_pass_front, dppass)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_config(&depth_pass_back, dppass)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } change_stencil_settings(); @@ -406,26 +406,26 @@ void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { switch (face) { case GL_FRONT: if (!change_stencil_func_config(&stencil_func_front, func)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; stencil_mask_front = mask; stencil_ref_front = ref; break; case GL_BACK: if (!change_stencil_func_config(&stencil_func_back, func)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; stencil_mask_back = mask; stencil_ref_back = ref; break; case GL_FRONT_AND_BACK: if (!change_stencil_func_config(&stencil_func_front, func)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; if (!change_stencil_func_config(&stencil_func_back, func)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; stencil_mask_front = stencil_mask_back = mask; stencil_ref_front = stencil_ref_back = ref; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } change_stencil_settings(); @@ -448,7 +448,7 @@ void glStencilMaskSeparate(GLenum face, GLuint mask) { stencil_mask_front_write = stencil_mask_back_write = mask; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; return; } change_stencil_settings(); diff --git a/deps/vitaGL/source/textures.c b/deps/vitaGL/source/textures.c index f86d21dcf0..4e9ce23f37 100644 --- a/deps/vitaGL/source/textures.c +++ b/deps/vitaGL/source/textures.c @@ -19,7 +19,7 @@ void glGenTextures(GLsizei n, GLuint *res) { #ifndef SKIP_ERROR_HANDLING // Error handling if (n < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -49,7 +49,7 @@ void glBindTexture(GLenum target, GLuint texture) { tex_unit->tex_id = texture; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -58,7 +58,7 @@ void glDeleteTextures(GLsizei n, const GLuint *gl_textures) { #ifndef SKIP_ERROR_HANDLING // Error handling if (n < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -119,7 +119,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei widt data_bpp = 1; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -131,7 +131,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei widt data_bpp = 2; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -142,7 +142,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei widt read_cb = readRGB; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -157,7 +157,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei widt read_cb = readRGBA5551; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -197,13 +197,13 @@ void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei widt tex_format = SCE_GXM_TEXTURE_FORMAT_P8_ABGR; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } // Checking if texture is too big for sceGxm if (width > GXM_TEX_MAX_SIZE || height > GXM_TEX_MAX_SIZE) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } @@ -227,7 +227,7 @@ void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei widt break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -266,7 +266,7 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, G data_bpp = 1; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -277,7 +277,7 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, G data_bpp = 2; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -288,7 +288,7 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, G read_cb = readRGB; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -303,7 +303,7 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, G read_cb = readRGBA5551; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; @@ -349,7 +349,7 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, G break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -370,12 +370,12 @@ void glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum fo bpp = 4; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } @@ -409,7 +409,7 @@ void glTexParameteri(GLenum target, GLenum pname, GLint param) { case GL_LINEAR_MIPMAP_LINEAR: // TODO: Implement this break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } sceGxmTextureSetMinFilter(&tex->gxm_tex, tex_unit->min_filter); @@ -431,7 +431,7 @@ void glTexParameteri(GLenum target, GLenum pname, GLint param) { case GL_LINEAR_MIPMAP_LINEAR: // TODO: Implement this break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } sceGxmTextureSetMagFilter(&tex->gxm_tex, tex_unit->mag_filter); @@ -448,7 +448,7 @@ void glTexParameteri(GLenum target, GLenum pname, GLint param) { tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_MIRROR; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } sceGxmTextureSetUAddrMode(&tex->gxm_tex, tex_unit->u_mode); @@ -465,18 +465,18 @@ void glTexParameteri(GLenum target, GLenum pname, GLint param) { tex_unit->v_mode = SCE_GXM_TEXTURE_ADDR_MIRROR; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -523,12 +523,12 @@ void glTexParameterf(GLenum target, GLenum pname, GLfloat param) { sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -537,7 +537,7 @@ void glActiveTexture(GLenum texture) { // Changing current in use server texture unit #ifndef SKIP_ERROR_HANDLING if ((texture < GL_TEXTURE0) && (texture > GL_TEXTURE31)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; else #endif server_texture_unit = texture - GL_TEXTURE0; @@ -570,7 +570,7 @@ void glGenerateMipmap(GLenum target) { break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -596,12 +596,12 @@ void glTexEnvf(GLenum target, GLenum pname, GLfloat param) { tex_unit->env_mode = ADD; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; } } @@ -633,12 +633,12 @@ void glTexEnvi(GLenum target, GLenum pname, GLint param) { } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -654,7 +654,7 @@ void *vglGetTexDataPointer(GLenum target) { return tex->data; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } diff --git a/deps/vitaGL/source/vitaGL.c b/deps/vitaGL/source/vitaGL.c index fca274a12e..67526abdf9 100644 --- a/deps/vitaGL/source/vitaGL.c +++ b/deps/vitaGL/source/vitaGL.c @@ -697,7 +697,7 @@ void glGenBuffers(GLsizei n, GLuint *res) { int i = 0, j = 0; #ifndef SKIP_ERROR_HANDLING if (n < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -714,7 +714,7 @@ void glGenBuffers(GLsizei n, GLuint *res) { void glBindBuffer(GLenum target, GLuint buffer) { #ifndef SKIP_ERROR_HANDLING if ((buffer != 0x0000) && ((buffer >= BUFFERS_ADDR + BUFFERS_NUM) || (buffer < BUFFERS_ADDR))) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -726,7 +726,7 @@ void glBindBuffer(GLenum target, GLuint buffer) { index_array_unit = buffer - BUFFERS_ADDR; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -734,7 +734,7 @@ void glBindBuffer(GLenum target, GLuint buffer) { void glDeleteBuffers(GLsizei n, const GLuint *gl_buffers) { #ifndef SKIP_ERROR_HANDLING if (n < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -754,7 +754,7 @@ void glDeleteBuffers(GLsizei n, const GLuint *gl_buffers) { void glBufferData(GLenum target, GLsizei size, const GLvoid *data, GLenum usage) { #ifndef SKIP_ERROR_HANDLING if (size < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -767,7 +767,7 @@ void glBufferData(GLenum target, GLsizei size, const GLvoid *data, GLenum usage) idx = index_array_unit; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } vglMemType type = VGL_MEM_VRAM; @@ -811,7 +811,7 @@ void glBlendFunc(GLenum sfactor, GLenum dfactor) { blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } switch (dfactor) { @@ -849,7 +849,7 @@ void glBlendFunc(GLenum sfactor, GLenum dfactor) { blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } if (blend_state) @@ -892,7 +892,7 @@ void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum d blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } switch (dstRGB) { @@ -930,7 +930,7 @@ void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum d blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } switch (srcAlpha) { @@ -968,7 +968,7 @@ void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum d blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } switch (dstAlpha) { @@ -1006,7 +1006,7 @@ void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum d blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } if (blend_state) @@ -1031,7 +1031,7 @@ void glBlendEquation(GLenum mode) { blend_func_rgb = blend_func_a = SCE_GXM_BLEND_FUNC_MAX; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } if (blend_state) @@ -1056,7 +1056,7 @@ void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { blend_func_rgb = SCE_GXM_BLEND_FUNC_MAX; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } switch (modeAlpha) { @@ -1076,7 +1076,7 @@ void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { blend_func_a = SCE_GXM_BLEND_FUNC_MAX; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } if (blend_state) @@ -1102,7 +1102,7 @@ void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { #ifndef SKIP_ERROR_HANDLING if ((stride < 0) || ((size < 2) && (size > 4))) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -1115,7 +1115,7 @@ void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *poin tex_unit->vertex_array.size = sizeof(GLshort); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } @@ -1127,7 +1127,7 @@ void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *poin void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { #ifndef SKIP_ERROR_HANDLING if ((stride < 0) || ((size < 3) && (size > 4))) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -1140,7 +1140,7 @@ void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *point tex_unit->color_array.size = sizeof(GLshort); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } @@ -1152,7 +1152,7 @@ void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *point void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { #ifndef SKIP_ERROR_HANDLING if ((stride < 0) || ((size < 2) && (size > 4))) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -1165,7 +1165,7 @@ void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *po tex_unit->texture_array.size = sizeof(GLshort); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } @@ -1207,7 +1207,7 @@ void glDrawArrays(GLenum mode, GLint first, GLsizei count) { skip_draw = GL_TRUE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } if (!skip_draw) { @@ -1473,11 +1473,11 @@ void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *gl_in if (tex_unit->vertex_array_state) { #ifndef SKIP_ERROR_HANDLING if (type != GL_UNSIGNED_SHORT) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; else if (phase == MODEL_CREATION) - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; else if (count < 0) - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; #endif switch (mode) { case GL_POINTS: @@ -1502,7 +1502,7 @@ void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *gl_in skip_draw = GL_TRUE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } if (!skip_draw) { @@ -1739,7 +1739,7 @@ void glEnableClientState(GLenum array) { tex_unit->texture_array_state = GL_TRUE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -1757,7 +1757,7 @@ void glDisableClientState(GLenum array) { tex_unit->texture_array_state = GL_FALSE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } } @@ -1765,7 +1765,7 @@ void glDisableClientState(GLenum array) { void glClientActiveTexture(GLenum texture) { #ifndef SKIP_ERROR_HANDLING if ((texture < GL_TEXTURE0) && (texture > GL_TEXTURE31)) - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; else #endif client_texture_unit = texture - GL_TEXTURE0; @@ -1776,7 +1776,7 @@ void glClientActiveTexture(GLenum texture) { void vglVertexPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { #ifndef SKIP_ERROR_HANDLING if ((stride < 0) || ((size < 2) && (size > 4))) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -1790,7 +1790,7 @@ void vglVertexPointer(GLint size, GLenum type, GLsizei stride, GLuint count, con bpe = sizeof(GLshort); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } tex_unit->vertex_object = gpu_pool_memalign(count * bpe * size, bpe * size); @@ -1811,7 +1811,7 @@ void vglVertexPointer(GLint size, GLenum type, GLsizei stride, GLuint count, con void vglColorPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { #ifndef SKIP_ERROR_HANDLING if ((stride < 0) || ((size < 3) && (size > 4))) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -1828,7 +1828,7 @@ void vglColorPointer(GLint size, GLenum type, GLsizei stride, GLuint count, cons bpe = sizeof(uint8_t); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } tex_unit->color_object = gpu_pool_memalign(count * bpe * size, bpe * size); @@ -1850,7 +1850,7 @@ void vglColorPointer(GLint size, GLenum type, GLsizei stride, GLuint count, cons void vglTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { #ifndef SKIP_ERROR_HANDLING if ((stride < 0) || ((size < 2) && (size > 4))) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -1864,7 +1864,7 @@ void vglTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLuint count, c bpe = sizeof(GLshort); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } tex_unit->texture_object = gpu_pool_memalign(count * bpe * size, bpe * size); @@ -1885,7 +1885,7 @@ void vglTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLuint count, c void vglIndexPointer(GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { #ifndef SKIP_ERROR_HANDLING if (stride < 0) { - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; return; } #endif @@ -1899,7 +1899,7 @@ void vglIndexPointer(GLenum type, GLsizei stride, GLuint count, const GLvoid *po bpe = sizeof(GLshort); break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } tex_unit->index_object = gpu_pool_memalign(count * bpe, bpe); @@ -1944,9 +1944,9 @@ void vglDrawObjects(GLenum mode, GLsizei count, GLboolean implicit_wvp) { int texture2d_idx = tex_unit->tex_id; #ifndef SKIP_ERROR_HANDLING if (phase == MODEL_CREATION) - error = GL_INVALID_OPERATION; + _vitagl_error = GL_INVALID_OPERATION; else if (count < 0) - error = GL_INVALID_VALUE; + _vitagl_error = GL_INVALID_VALUE; #endif GLboolean skip_draw = GL_FALSE; switch (mode) { @@ -1972,7 +1972,7 @@ void vglDrawObjects(GLenum mode, GLsizei count, GLboolean implicit_wvp) { skip_draw = GL_TRUE; break; default: - error = GL_INVALID_ENUM; + _vitagl_error = GL_INVALID_ENUM; break; } if (!skip_draw) { From d1aa7dbedc5f99247b4a2c2436594efb5a1413c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Fri, 13 Dec 2019 11:28:50 +0100 Subject: [PATCH 3/9] Disable not compilable sqrtfv_neon --- deps/math-neon/source/math_sqrtfv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/math-neon/source/math_sqrtfv.c b/deps/math-neon/source/math_sqrtfv.c index c657db5d34..c647403a28 100644 --- a/deps/math-neon/source/math_sqrtfv.c +++ b/deps/math-neon/source/math_sqrtfv.c @@ -100,7 +100,7 @@ void sqrtfv_c(float *x, int n, float *r) void sqrtfv_neon(float *x, int n, float *r) { -#ifdef __MATH_NEON +#if 0 asm volatile ( "tst r1, #1 \n\t" //r1 & 1 From 0be7e964373ca196bd7ae7e73657146f60eaa380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Fri, 13 Dec 2019 11:29:14 +0100 Subject: [PATCH 4/9] (Vita) Disable lto --- Makefile.vita | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.vita b/Makefile.vita index c61a153746..5fea88d2cf 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -87,7 +87,7 @@ LD := $(CXX) LIBDIRS := -L. ARCHFLAGS := -march=armv7-a -mfpu=neon -mfloat-abi=hard -DVITA -CFLAGS += $(ARCHFLAGS) -mword-relocations -fno-optimize-sibling-calls -O2 -flto +CFLAGS += $(ARCHFLAGS) -mword-relocations -fno-optimize-sibling-calls -O2 ifeq ($(DEBUG), 1) CFLAGS += -g From 8ad3cb14f8f7369c197b3835cb43a06e1314d256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 14 Dec 2019 14:02:40 +0100 Subject: [PATCH 5/9] (Vita) Changes for new tint shaders --- Makefile.common | 1 + deps/libvita2d/include/shared.h | 3 +- deps/libvita2d/include/vita2d.h | 14 ++- deps/libvita2d/shader/texture_tint_f_gxp.c | 42 +++---- deps/libvita2d/shader/texture_tint_v_gxp.c | 28 +++++ deps/libvita2d/source/vita2d.c | 66 +++++++++- deps/libvita2d/source/vita2d_texture.c | 139 +++++++++++++++++---- 7 files changed, 237 insertions(+), 56 deletions(-) create mode 100644 deps/libvita2d/shader/texture_tint_v_gxp.c diff --git a/Makefile.common b/Makefile.common index 477c6a8496..41d7f859ad 100644 --- a/Makefile.common +++ b/Makefile.common @@ -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) diff --git a/deps/libvita2d/include/shared.h b/deps/libvita2d/include/shared.h index 6c67fcb00e..6dd0a086c3 100644 --- a/deps/libvita2d/include/shared.h +++ b/deps/libvita2d/include/shared.h @@ -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 diff --git a/deps/libvita2d/include/vita2d.h b/deps/libvita2d/include/vita2d.h index c19ac6ed5a..d1f54058b5 100644 --- a/deps/libvita2d/include/vita2d.h +++ b/deps/libvita2d/include/vita2d.h @@ -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); diff --git a/deps/libvita2d/shader/texture_tint_f_gxp.c b/deps/libvita2d/shader/texture_tint_f_gxp.c index 3d14207221..0fba5c8b28 100644 --- a/deps/libvita2d/shader/texture_tint_f_gxp.c +++ b/deps/libvita2d/shader/texture_tint_f_gxp.c @@ -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; diff --git a/deps/libvita2d/shader/texture_tint_v_gxp.c b/deps/libvita2d/shader/texture_tint_v_gxp.c new file mode 100644 index 0000000000..fe62b86c72 --- /dev/null +++ b/deps/libvita2d/shader/texture_tint_v_gxp.c @@ -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; diff --git a/deps/libvita2d/source/vita2d.c b/deps/libvita2d/source/vita2d.c index f76a860115..801bb76214 100644 --- a/deps/libvita2d/source/vita2d.c +++ b/deps/libvita2d/source/vita2d.c @@ -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); diff --git a/deps/libvita2d/source/vita2d_texture.c b/deps/libvita2d/source/vita2d_texture.c index 4cb19c7885..d280978898 100644 --- a/deps/libvita2d/source/vita2d_texture.c +++ b/deps/libvita2d/source/vita2d_texture.c @@ -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); From 3d44faf6c37e1fbe9e6b73e9e3c4d26c886569a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 14 Dec 2019 14:04:53 +0100 Subject: [PATCH 6/9] (Vita) New set viewport function --- deps/libvita2d/include/vita2d.h | 1 + deps/libvita2d/source/vita2d.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/deps/libvita2d/include/vita2d.h b/deps/libvita2d/include/vita2d.h index d1f54058b5..d649e91aa8 100644 --- a/deps/libvita2d/include/vita2d.h +++ b/deps/libvita2d/include/vita2d.h @@ -89,6 +89,7 @@ int vita2d_get_clipping_enabled(); void vita2d_set_clip_rectangle(int x_min, int y_min, int x_max, int y_max); void vita2d_get_clip_rectangle(int *x_min, int *y_min, int *x_max, int *y_max); void vita2d_set_blend_mode_add(int enable); +void vita2d_set_viewport(int x, int y, int width, int height); void *vita2d_pool_malloc(unsigned int size); void *vita2d_pool_memalign(unsigned int size, unsigned int alignment); diff --git a/deps/libvita2d/source/vita2d.c b/deps/libvita2d/source/vita2d.c index 801bb76214..0ec5900f92 100644 --- a/deps/libvita2d/source/vita2d.c +++ b/deps/libvita2d/source/vita2d.c @@ -1091,4 +1091,15 @@ void vita2d_set_blend_mode_add(int enable) _vita2d_colorFragmentProgram = in->color; _vita2d_textureFragmentProgram = in->texture; _vita2d_textureTintFragmentProgram = in->textureTint; +} + +void vita2d_set_viewport(int x, int y, int width, int height){ + static float vh = DISPLAY_HEIGHT; + float sw = width / 2.; + float sh = height / 2.; + float x_scale = sw; + float x_port = x + sw; + float y_scale = -(sh); + float y_port = vh - y - sh; + sceGxmSetViewport(_vita2d_context, x_port, x_scale, y_port, y_scale, -0.5f, 0.5f); } \ No newline at end of file From d52f3ba3e9a9b5b19f33633f8e87a0bc889271c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 14 Dec 2019 14:08:06 +0100 Subject: [PATCH 7/9] (Vita) Fix clipping and reduce number of calls --- deps/libvita2d/source/vita2d.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deps/libvita2d/source/vita2d.c b/deps/libvita2d/source/vita2d.c index 0ec5900f92..8eb674bda9 100644 --- a/deps/libvita2d/source/vita2d.c +++ b/deps/libvita2d/source/vita2d.c @@ -933,12 +933,16 @@ int vita2d_get_clipping_enabled() void vita2d_set_clip_rectangle(int x_min, int y_min, int x_max, int y_max) { + vita2d_set_viewport(0,0,DISPLAY_WIDTH,DISPLAY_HEIGHT); + clipping_enabled = 1; clip_rect_x_min = x_min; clip_rect_y_min = y_min; clip_rect_x_max = x_max; clip_rect_y_max = y_max; // we can only draw during a scene, but we can cache the values since they're not going to have any visible effect till the scene starts anyways if(drawing) { + sceGxmSetFrontDepthWriteEnable(_vita2d_context, + SCE_GXM_DEPTH_WRITE_DISABLED); // clear the stencil buffer to 0 sceGxmSetFrontStencilFunc( _vita2d_context, @@ -959,6 +963,8 @@ void vita2d_set_clip_rectangle(int x_min, int y_min, int x_max, int y_max) 0xFF, 0xFF); vita2d_draw_rectangle(x_min, y_min, x_max - x_min, y_max - y_min, 0); + sceGxmSetFrontDepthWriteEnable(_vita2d_context, + SCE_GXM_DEPTH_WRITE_ENABLED); if(clipping_enabled) { // set the stencil function to only accept pixels where the stencil is 1 sceGxmSetFrontStencilFunc( From 9ad874eef8ed699e5c8d9343857cfffe699c3abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 14 Dec 2019 14:08:57 +0100 Subject: [PATCH 8/9] (Vita) Add new function to draw textured arrays of vertices --- deps/libvita2d/include/vita2d.h | 1 + deps/libvita2d/source/vita2d_texture.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/deps/libvita2d/include/vita2d.h b/deps/libvita2d/include/vita2d.h index d649e91aa8..0836f8662f 100644 --- a/deps/libvita2d/include/vita2d.h +++ b/deps/libvita2d/include/vita2d.h @@ -140,6 +140,7 @@ void vita2d_draw_texture_tint_scale_rotate_hotspot(const vita2d_texture *texture void vita2d_draw_texture_tint_scale_rotate(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, float rad, unsigned int color); void vita2d_draw_texture_part_tint_scale_rotate(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, float rad, unsigned int color); void vita2d_draw_array_textured(const vita2d_texture *texture, SceGxmPrimitiveType mode, const vita2d_texture_vertex *vertices, size_t count, unsigned int color); +void vita2d_draw_array_textured_mat(const vita2d_texture *texture, const vita2d_texture_tint_vertex *vertices, size_t count, float *mat); /** ADVANCED **/ void vita2d_texture_set_wvp(float x, float y, float width, float height); diff --git a/deps/libvita2d/source/vita2d_texture.c b/deps/libvita2d/source/vita2d_texture.c index d280978898..431e7fbed9 100644 --- a/deps/libvita2d/source/vita2d_texture.c +++ b/deps/libvita2d/source/vita2d_texture.c @@ -873,3 +873,18 @@ void vita2d_draw_array_textured(const vita2d_texture *texture, SceGxmPrimitiveTy sceGxmSetVertexStream(_vita2d_context, 0, vertices); sceGxmDraw(_vita2d_context, mode, SCE_GXM_INDEX_FORMAT_U16, vita2d_get_linear_indices(), count); } + +void vita2d_draw_array_textured_mat(const vita2d_texture *texture, const vita2d_texture_tint_vertex *vertices, size_t count, float *mat) +{ + set_texture_tint_program(); + + void *vertex_wvp_buffer; + sceGxmReserveVertexDefaultUniformBuffer(_vita2d_context, &vertex_wvp_buffer); + sceGxmSetUniformDataF(vertex_wvp_buffer, _vita2d_textureWvpParam, 0, 16, mat); + + // 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(), count); +} \ No newline at end of file From b4be7b0c74d12f717bc3690760f621af57f93a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 14 Dec 2019 14:11:09 +0100 Subject: [PATCH 9/9] (Vita) Several improvements to vita2d driver --- Makefile.vita | 1 + gfx/drivers/vita2d_gfx.c | 35 +++++- gfx/drivers_font/vita2d_font.c | 5 + menu/drivers_display/menu_display_vita2d.c | 140 +++++++++------------ 4 files changed, 91 insertions(+), 90 deletions(-) diff --git a/Makefile.vita b/Makefile.vita index 5fea88d2cf..4d1909346e 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -41,6 +41,7 @@ else HAVE_SOCKET_LEGACY := 1 HAVE_MENU := 1 HAVE_MENU_COMMON := 1 + HAVE_MENU_WIDGETS = 1 HAVE_OVERLAY := 1 HAVE_VIDEO_LAYOUT := 0 HAVE_MATERIALUI := 1 diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 2c6008c9de..feb11dc8a3 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -26,6 +26,9 @@ #ifdef HAVE_MENU #include "../../menu/menu_driver.h" +#ifdef HAVE_MENU_WIDGETS +#include "../../menu/widgets/menu_widgets.h" +#endif #endif #include "../font_driver.h" @@ -210,11 +213,6 @@ static bool vita2d_gfx_frame(void *data, const void *frame, } } -#ifdef HAVE_OVERLAY - if (vita->overlay_enable) - vita2d_render_overlay(vita); -#endif - if (vita->menu.active) { #ifdef HAVE_MENU @@ -261,6 +259,15 @@ static bool vita2d_gfx_frame(void *data, const void *frame, } } + #ifdef HAVE_OVERLAY + if (vita->overlay_enable) + vita2d_render_overlay(vita); + #endif + + #ifdef HAVE_MENU_WIDGETS + menu_widgets_frame(video_info); + #endif + if(!string_is_empty(msg)) font_driver_render_msg(video_info, NULL, msg, NULL); @@ -447,7 +454,7 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, int x = 0; int y = 0; float device_aspect = (float)viewport_width / viewport_height; - struct video_ortho ortho = {0, 1, 1, 0, -1, 1}; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; settings_t *settings = config_get_ptr(); vita_video_t *vita = (vita_video_t*)data; @@ -518,6 +525,7 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, vita->vp.height = viewport_height; } + vita2d_set_viewport(vita->vp.x, vita->vp.y, vita->vp.width, vita->vp.height); vita2d_set_projection(vita, &ortho, allow_rotate); /* Set last backbuffer viewport. */ @@ -543,12 +551,15 @@ static void vita2d_gfx_set_rotation(void *data, unsigned rotation) { vita_video_t *vita = (vita_video_t*)data; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; if (!vita) return; vita->rotation = rotation; vita->should_resize = true; + vita2d_set_projection(vita, &ortho, true); + } static void vita2d_gfx_viewport_info(void *data, @@ -794,6 +805,14 @@ static void vita2d_gfx_get_poke_interface(void *data, *iface = &vita_poke_interface; } +#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) +static bool vita2d_gfx_menu_widgets_enabled(void *data) +{ + (void)data; + return true; +} +#endif + #ifdef HAVE_OVERLAY static void vita2d_overlay_tex_geom(void *data, unsigned image, float x, float y, float w, float h); static void vita2d_overlay_vertex_geom(void *data, unsigned image, float x, float y, float w, float h); @@ -954,4 +973,8 @@ video_driver_t video_vita2d = { NULL, #endif vita2d_gfx_get_poke_interface, + NULL, +#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) + vita2d_gfx_menu_widgets_enabled +#endif }; diff --git a/gfx/drivers_font/vita2d_font.c b/gfx/drivers_font/vita2d_font.c index 7f5ef08485..60c11d7df2 100644 --- a/gfx/drivers_font/vita2d_font.c +++ b/gfx/drivers_font/vita2d_font.c @@ -271,6 +271,7 @@ static void vita2d_font_render_msg( int drop_x, drop_y; unsigned max_glyphs; enum text_alignment text_align; + bool full_screen = false ; unsigned color, color_dark, r, g, b, alpha, r_dark, g_dark, b_dark, alpha_dark; vita_font_t *font = (vita_font_t *)data; @@ -285,6 +286,7 @@ static void vita2d_font_render_msg( x = params->x; y = params->y; scale = params->scale; + full_screen = params->full_screen; text_align = params->text_align; drop_x = params->drop_x; drop_y = params->drop_y; @@ -301,6 +303,7 @@ static void vita2d_font_render_msg( x = video_info->font_msg_pos_x; y = video_info->font_msg_pos_y; scale = 1.0f; + full_screen = true; text_align = TEXT_ALIGN_LEFT; r = (video_info->font_msg_color_r * 255); @@ -315,6 +318,8 @@ static void vita2d_font_render_msg( drop_alpha = 1.0f; } + video_driver_set_viewport(width, height, full_screen, false); + max_glyphs = strlen(msg); if (drop_x || drop_y) diff --git a/menu/drivers_display/menu_display_vita2d.c b/menu/drivers_display/menu_display_vita2d.c index 291a573cbf..e62a964121 100644 --- a/menu/drivers_display/menu_display_vita2d.c +++ b/menu/drivers_display/menu_display_vita2d.c @@ -36,10 +36,17 @@ static const float vita2d_vertexes[] = { }; static const float vita2d_tex_coords[] = { - 0, 0, - 1, 0, 0, 1, - 1, 1 + 1, 1, + 0, 0, + 1, 0 +}; + +static const float vita2d_colors[] = { + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, }; static const float *menu_display_vita2d_get_default_vertices(void) @@ -47,6 +54,11 @@ static const float *menu_display_vita2d_get_default_vertices(void) return &vita2d_vertexes[0]; } +static const float *menu_display_vita2d_get_default_color(void) +{ + return &vita2d_colors[0]; +} + static const float *menu_display_vita2d_get_default_tex_coords(void) { return &vita2d_tex_coords[0]; @@ -63,25 +75,6 @@ static void *menu_display_vita2d_get_default_mvp( return &vita2d->mvp_no_rot; } -#if 0 -static SceGxmPrimitiveType menu_display_prim_to_vita2d_enum( - enum menu_display_prim_type type) -{ - switch (type) - { - case MENU_DISPLAY_PRIM_TRIANGLESTRIP: - return SCE_GXM_PRIMITIVE_TRIANGLE_STRIP; - case MENU_DISPLAY_PRIM_TRIANGLES: - return SCE_GXM_PRIMITIVE_TRIANGLES; - case MENU_DISPLAY_PRIM_NONE: - default: - break; - } - - return 0; -} -#endif - static void menu_display_vita2d_blend_begin(video_frame_info_t *video_info) { @@ -95,25 +88,22 @@ static void menu_display_vita2d_blend_end(video_frame_info_t *video_info) static void menu_display_vita2d_viewport(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info) { -#if 0 - vita2d_texture_set_wvp(draw->x, draw->y, draw->width, draw->height); -#endif + if (draw){ + vita2d_set_viewport(draw->x, draw->y, draw->width, draw->height); + } } static void menu_display_vita2d_draw(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info) { -#if 0 unsigned i; -#endif - unsigned int tex_width, tex_height; struct vita2d_texture *texture = NULL; const float *vertex = NULL; const float *tex_coord = NULL; const float *color = NULL; vita_video_t *vita2d = (vita_video_t*)video_info->userdata; - if (!vita2d || !draw) + if (!vita2d || !draw) return; texture = (struct vita2d_texture*)draw->texture; @@ -129,63 +119,35 @@ static void menu_display_vita2d_draw(menu_display_ctx_draw_t *draw, draw->coords->lut_tex_coord = menu_display_vita2d_get_default_tex_coords(); if (!texture) return; -#if 0 - texture = &vk->display.blank_texture;*/ -#endif + if (!color) + color = menu_display_vita2d_get_default_color(); - tex_width = vita2d_texture_get_width(texture); - tex_height = vita2d_texture_get_height(texture); + menu_display_vita2d_viewport(draw, video_info); + + vita2d_texture_tint_vertex *vertices = (vita2d_texture_tint_vertex *)vita2d_pool_memalign( + draw->coords->vertices * sizeof(vita2d_texture_tint_vertex), + sizeof(vita2d_texture_tint_vertex)); -#if 0 - vita2d_texture_set_program(); - menu_display_vita2d_viewport(draw); - - RARCH_LOG("DRAW BG %d %d \n",draw->width,draw->height); - - vita2d_texture_vertex *pv = (vita2d_texture_vertex *)vita2d_pool_memalign( - draw->coords->vertices * sizeof(vita2d_texture_vertex), // 4 vertices - sizeof(vita2d_texture_vertex)); - - for (i = 0; i < draw->coords->vertices; i++) - { - pv[i].x = *vertex++; - pv[i].y = *vertex++; // Y-flip. Vulkan is top-left clip space - pv[i].z = +0.5f; - pv[i].u = *tex_coord++; - pv[i].v = *tex_coord++; - snprintf(msg, sizeof(msg), "%.2f %.2f %.2f %.2f %.2f\n",pv[i].x,pv[i].y,pv[i].z,pv[i].u,pv[i].v); - RARCH_LOG(msg); - RARCH_LOG("%x %x %x %x %x\n",pv[i].x,pv[i].y,pv[i].z,pv[i].u,pv[i].v); + for(i = 0; i < draw->coords->vertices; i++){ + vertices[i].x = *vertex++; + vertices[i].y = *vertex++; + vertices[i].z = 1.0f; + vertices[i].u = *tex_coord++; + vertices[i].v = *tex_coord++; + vertices[i].r = *color++; + vertices[i].g = *color++; + vertices[i].b = *color++; + vertices[i].a = *color++; } -#endif + + const math_matrix_4x4 *mat = draw->matrix_data + ? (const math_matrix_4x4*)draw->matrix_data : (const math_matrix_4x4*)menu_display_vita2d_get_default_mvp(video_info); switch (draw->pipeline.id) { default: { - - int colorR = (int)((*color++)*255.f); - int colorG = (int)((*color++)*255.f); - int colorB = (int)((*color++)*255.f); - int colorA = (int)((*color++)*255.f); - -#if 0 - vita2d_texture_set_tint_color_uniform(RGBA8((int)((*color++)*255.f), (int)((*color++)*255.f), (int)((*color++)*255.f), (int)((*color++)*255.f))); - vita2d_texture_set_tint_color_uniform(RGBA8(0xFF, 0xFF, 0xFF, 0xAA)); - vita2d_draw_texture_part_generic(texture, menu_display_prim_to_vita2d_enum( - draw->prim_type), pv, draw->coords->vertices); -#endif - - vita2d_draw_texture_tint_scale(texture, draw->x, - PSP_FB_HEIGHT-draw->y-draw->height, - (float)draw->width/(float)tex_width, - (float)draw->height/(float)tex_height, - RGBA8(colorR,colorG,colorB,colorA)); - -#if 0 - if(texture) - vita2d_draw_texture(NULL,0,0); -#endif + vita2d_draw_array_textured_mat(texture, vertices, draw->coords->vertices, menu_display_vita2d_get_default_mvp(video_info)); break; } } @@ -211,10 +173,7 @@ static void menu_display_vita2d_clear_color( (int)(clearcolor->g*255.f), (int)(clearcolor->b*255.f), (int)(clearcolor->a*255.f))); - vita2d_draw_rectangle(0,0,PSP_FB_WIDTH,PSP_FB_HEIGHT,RGBA8((int)(clearcolor->r*255.f), - (int)(clearcolor->g*255.f), - (int)(clearcolor->b*255.f), - (int)(clearcolor->a*255.f))); + vita2d_draw_rectangle(0,0,PSP_FB_WIDTH,PSP_FB_HEIGHT, vita2d_get_clear_color()); } static bool menu_display_vita2d_font_init_first( @@ -230,6 +189,19 @@ static bool menu_display_vita2d_font_init_first( return *handle; } +static void menu_display_vita2d_scissor_end(video_frame_info_t *video_info) +{ + vita2d_set_region_clip(SCE_GXM_REGION_CLIP_NONE, 0, 0, video_info->width, video_info->height); + vita2d_disable_clipping(); +} + +static void menu_display_vita2d_scissor_begin(video_frame_info_t *video_info, int x, int y, + unsigned width, unsigned height) +{ + vita2d_set_clip_rectangle(x, y, x + width, y + height); + vita2d_set_region_clip(SCE_GXM_REGION_CLIP_OUTSIDE, x, y, x + width, y + height); +} + menu_display_ctx_driver_t menu_display_ctx_vita2d = { menu_display_vita2d_draw, menu_display_vita2d_draw_pipeline, @@ -245,6 +217,6 @@ menu_display_ctx_driver_t menu_display_ctx_vita2d = { MENU_VIDEO_DRIVER_VITA2D, "vita2d", true, - NULL, - NULL + menu_display_vita2d_scissor_begin, + menu_display_vita2d_scissor_end };