mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 04:20:28 +00:00
81403e2751 Fix error requiring HAVE_SHARK to be enabled to build. (#45) 58551e1f52 Added possibility to change runtime shader compiler optimization flags. 77ab50a7b1 Added GL_BGR and GL_BGRA texture formats support. 0ac2793bcf Fix error in texture wrapping options. (#42) 0d2110ac7b Improvements to GL buffer support. (#41) cf86149a85 Added proper compressed texture support. (#40) 8b0a0f735a Unbinded textures and texture units concepts. 1b04851efc Added glUniform2i and glUniform2f implementations. 9a65397ef6 Properly checking for uniform locations existence. 91c557f35d Added support for GL_SHORT attribute types for shaders. 3237fd3fe3 Added vglTexImageDepthBuffer function. f58b3818f2 Typo fix on mag filter setting. ee11f7e1d0 Added vglHasRuntimeShaderCompiler function. 3596242f73 Add PowerVR texture compression (PVRTC) support (#39) 2ae694df4b Added support for mipmaps filtering. af7804b44c Added vglGetGxmTexture implementation. 54b1df4ca2 Removed unused arguments. 7c2ed742ee Allow to call vglBind*Location funcs with wrong param names. 8be84ff698 Fixed RGB565 color conversion. 234ff57f65 Properly setting a single stream with packed attributes. d3b28a5e32 Fix for correct vglBindAttribLocation behaviour. 46e72d3564 Use a single stream for packed attributes. 72a39315e9 Properly dealing with missing attrs in glGetUniformLocation. a6269ce574 Added TEXUNIT1 support for custom shaders. 824d43073e Resetting custom shaders uniforms only when invalidated. d242570161 Minor fix in glShaderSource. bc28bd946d Added glGetShaderInfoLog implementation. git-subtree-dir: deps/vitaGL git-subtree-split: 81403e2751c4dc28cf17cc89a5ab053eb2c5af67
208 lines
8.2 KiB
C
208 lines
8.2 KiB
C
/*
|
|
* This file is part of vitaGL
|
|
* Copyright 2017, 2018, 2019, 2020 Rinnegatamante
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published
|
|
* by the Free Software Foundation, version 3 of the License, or (at your
|
|
* option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/*
|
|
* shared.h:
|
|
* All functions/definitions that shouldn't be exposed to
|
|
* end users but are used in multiple source files must be here
|
|
*/
|
|
|
|
#ifndef _SHARED_H_
|
|
#define _SHARED_H_
|
|
|
|
// Internal constants
|
|
#define TEXTURES_NUM 16384 // Available textures
|
|
#define COMPRESSED_TEXTURE_FORMATS_NUM 9 // The number of supported texture formats.
|
|
#define MODELVIEW_STACK_DEPTH 32 // Depth of modelview matrix stack
|
|
#define GENERIC_STACK_DEPTH 2 // Depth of generic matrix stack
|
|
#define DISPLAY_WIDTH_DEF 960 // Default display width in pixels
|
|
#define DISPLAY_HEIGHT_DEF 544 // Default display height in pixels
|
|
#define DISPLAY_BUFFER_COUNT 2 // Display buffers to use
|
|
#define GXM_TEX_MAX_SIZE 4096 // Maximum width/height in pixels per texture
|
|
#define BUFFERS_ADDR 0xA000 // Starting address for buffers indexing
|
|
#define BUFFERS_NUM 128 // Maximum number of allocatable buffers
|
|
|
|
// Internal constants set in bootup phase
|
|
extern int DISPLAY_WIDTH; // Display width in pixels
|
|
extern int DISPLAY_HEIGHT; // Display height in pixels
|
|
extern int DISPLAY_STRIDE; // Display stride in pixels
|
|
extern float DISPLAY_WIDTH_FLOAT; // Display width in pixels (float)
|
|
extern float DISPLAY_HEIGHT_FLOAT; // Display height in pixels (float)
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <vitasdk.h>
|
|
|
|
#include "vitaGL.h"
|
|
|
|
#include "utils/gpu_utils.h"
|
|
#include "utils/math_utils.h"
|
|
#include "utils/mem_utils.h"
|
|
|
|
#include "state.h"
|
|
#include "texture_callbacks.h"
|
|
|
|
#define SET_GL_ERROR(x) vgl_error = x; return;
|
|
|
|
// Texture environment mode
|
|
typedef enum texEnvMode {
|
|
MODULATE = 0,
|
|
DECAL = 1,
|
|
BLEND = 2,
|
|
ADD = 3,
|
|
REPLACE = 4
|
|
} texEnvMode;
|
|
|
|
// 3D vertex for position + 4D vertex for RGBA color struct
|
|
typedef struct rgba_vertex {
|
|
vector3f position;
|
|
vector4f color;
|
|
} rgba_vertex;
|
|
|
|
// 3D vertex for position + 3D vertex for RGB color struct
|
|
typedef struct rgb_vertex {
|
|
vector3f position;
|
|
vector3f color;
|
|
} rgb_vertex;
|
|
|
|
// 3D vertex for position + 2D vertex for UV map struct
|
|
typedef struct texture2d_vertex {
|
|
vector3f position;
|
|
vector2f texcoord;
|
|
} texture2d_vertex;
|
|
|
|
// Non native primitives implemented
|
|
typedef enum SceGxmPrimitiveTypeExtra {
|
|
SCE_GXM_PRIMITIVE_NONE = 0,
|
|
SCE_GXM_PRIMITIVE_QUADS = 1
|
|
} SceGxmPrimitiveTypeExtra;
|
|
|
|
#include "shaders.h"
|
|
|
|
// Internal stuffs
|
|
extern void *frag_uniforms;
|
|
extern void *vert_uniforms;
|
|
extern SceGxmMultisampleMode msaa_mode;
|
|
extern GLboolean use_extra_mem;
|
|
|
|
// Debugging tool
|
|
#ifdef ENABLE_LOG
|
|
void LOG(const char *format, ...);
|
|
#endif
|
|
|
|
// Logging callback for vitaShaRK
|
|
#if defined(HAVE_SHARK) && defined(HAVE_SHARK_LOG)
|
|
void shark_log_cb(const char *msg, shark_log_level msg_level, int line);
|
|
#endif
|
|
|
|
// Depending on SDK, these could be or not defined
|
|
#ifndef max
|
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
|
#endif
|
|
#ifndef min
|
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
#endif
|
|
|
|
extern uint8_t use_shark; // Flag to check if vitaShaRK should be initialized at vitaGL boot
|
|
extern uint8_t is_shark_online; // Current vitaShaRK status
|
|
|
|
// sceGxm viewport setup (NOTE: origin is on center screen)
|
|
extern float x_port;
|
|
extern float y_port;
|
|
extern float z_port;
|
|
extern float x_scale;
|
|
extern float y_scale;
|
|
extern float z_scale;
|
|
|
|
// Fullscreen sceGxm viewport (NOTE: origin is on center screen)
|
|
extern float fullscreen_x_port;
|
|
extern float fullscreen_y_port;
|
|
extern float fullscreen_z_port;
|
|
extern float fullscreen_x_scale;
|
|
extern float fullscreen_y_scale;
|
|
extern float fullscreen_z_scale;
|
|
|
|
extern SceGxmContext *gxm_context; // sceGxm context instance
|
|
extern GLenum vgl_error; // Error returned by glGetError
|
|
extern SceGxmShaderPatcher *gxm_shader_patcher; // sceGxmShaderPatcher shader patcher instance
|
|
extern void *gxm_depth_surface_addr; // Depth surface memblock starting address
|
|
extern uint8_t system_app_mode; // Flag for system app mode usage
|
|
|
|
extern matrix4x4 mvp_matrix; // ModelViewProjection Matrix
|
|
extern matrix4x4 projection_matrix; // Projection Matrix
|
|
extern matrix4x4 modelview_matrix; // ModelView Matrix
|
|
extern GLboolean mvp_modified; // Check if ModelViewProjection matrix needs to be recreated
|
|
|
|
extern GLuint cur_program; // Current in use custom program (0 = No custom program)
|
|
extern GLboolean vblank; // Current setting for VSync
|
|
|
|
extern GLenum orig_depth_test; // Original depth test state (used for depth test invalidation)
|
|
|
|
// Scissor test shaders
|
|
extern SceGxmFragmentProgram *scissor_test_fragment_program; // Scissor test fragment program
|
|
extern vector4f *scissor_test_vertices; // Scissor test region vertices
|
|
extern SceUID scissor_test_vertices_uid; // Scissor test vertices memblock id
|
|
|
|
extern uint16_t *depth_clear_indices; // Memblock starting address for clear screen indices
|
|
|
|
// Clear screen shaders
|
|
extern SceGxmVertexProgram *clear_vertex_program_patched; // Patched vertex program for clearing screen
|
|
extern vector4f *clear_vertices; // Memblock starting address for clear screen vertices
|
|
|
|
/* gxm.c */
|
|
void initGxm(void); // Inits sceGxm
|
|
void initGxmContext(void); // Inits sceGxm context
|
|
void termGxmContext(void); // Terms sceGxm context
|
|
void createDisplayRenderTarget(void); // Creates render target for the display
|
|
void destroyDisplayRenderTarget(void); // Destroys render target for the display
|
|
void initDisplayColorSurfaces(void); // Creates color surfaces for the display
|
|
void termDisplayColorSurfaces(void); // Destroys color surfaces for the display
|
|
void initDepthStencilBuffer(uint32_t w, uint32_t h, SceGxmDepthStencilSurface *surface, void **depth_buffer, void **stencil_buffer, vglMemType *depth_type, vglMemType *stencil_type); // Creates depth and stencil surfaces
|
|
void initDepthStencilSurfaces(void); // Creates depth and stencil surfaces for the display
|
|
void termDepthStencilSurfaces(void); // Destroys depth and stencil surfaces for the display
|
|
void startShaderPatcher(void); // Creates a shader patcher instance
|
|
void stopShaderPatcher(void); // Destroys a shader patcher instance
|
|
void waitRenderingDone(void); // Waits for rendering to be finished
|
|
|
|
/* tests.c */
|
|
void change_depth_write(SceGxmDepthWriteMode mode); // Changes current in use depth write mode
|
|
void change_depth_func(void); // Changes current in use depth test function
|
|
void invalidate_depth_test(void); // Invalidates depth test state
|
|
void validate_depth_test(void); // Resets original depth test state after invalidation
|
|
void change_stencil_settings(void); // Changes current in use stencil test parameters
|
|
GLboolean change_stencil_config(SceGxmStencilOp *cfg, GLenum new); // Changes current in use stencil test operation value
|
|
GLboolean change_stencil_func_config(SceGxmStencilFunc *cfg, GLenum new); // Changes current in use stencil test function value
|
|
void update_alpha_test_settings(void); // Changes current in use alpha test operation value
|
|
void update_scissor_test(void); // Changes current in use scissor test region
|
|
void resetScissorTestRegion(void); // Resets scissor test region to default values
|
|
|
|
/* blending.c */
|
|
void change_blend_factor(void); // Changes current blending settings for all used shaders
|
|
void disable_blend(void); // Disables blending for all used shaders
|
|
|
|
/* custom_shaders.c */
|
|
void resetCustomShaders(void); // Resets custom shaders
|
|
void changeCustomShadersBlend(SceGxmBlendInfo *blend_info); // Change SceGxmBlendInfo value to all custom shaders
|
|
void reloadCustomShader(void); // Reloads in use custom shader inside sceGxm
|
|
void _vglDrawObjects_CustomShadersIMPL(GLenum mode, GLsizei count, GLboolean implicit_wvp); // vglDrawObjects implementation for rendering with custom shaders
|
|
|
|
/* misc functions */
|
|
void vector4f_convert_to_local_space(vector4f *out, int x, int y, int width, int height); // Converts screen coords to local space
|
|
|
|
#endif
|