RetroArch/source/utils/gpu_utils.h
Francisco José García García 8838992085 Squashed 'deps/vitaGL/' changes from 2934af8af0..81403e2751
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
2020-10-16 20:24:43 +02:00

103 lines
3.1 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/>.
*/
/*
* gpu_utils.h:
* Header file for the GPU utilities exposed by gpu_utils.c
*/
#ifndef _GPU_UTILS_H_
#define _GPU_UTILS_H_
#include "mem_utils.h"
// Align a value to the requested alignment
#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1))
// Texture object struct
typedef struct texture {
SceGxmTexture gxm_tex;
void *data;
vglMemType mtype;
SceUID palette_UID;
SceUID depth_UID;
uint8_t used;
uint8_t valid;
uint32_t type;
void (*write_cb)(void *, uint32_t);
} texture;
// Palette object struct
typedef struct palette {
void *data;
vglMemType type;
} palette;
// Alloc a generic memblock into sceGxm mapped memory
void *gpu_alloc_mapped(size_t size, vglMemType *type);
// Alloc into sceGxm mapped memory a vertex USSE memblock
void *gpu_vertex_usse_alloc_mapped(size_t size, unsigned int *usse_offset);
// Dealloc from sceGxm mapped memory a vertex USSE memblock
void gpu_vertex_usse_free_mapped(void *addr);
// Alloc into sceGxm mapped memory a fragment USSE memblock
void *gpu_fragment_usse_alloc_mapped(size_t size, unsigned int *usse_offset);
// Dealloc from sceGxm mapped memory a fragment USSE memblock
void gpu_fragment_usse_free_mapped(void *addr);
// Reserve a memory space from vitaGL mempool
void *gpu_pool_malloc(unsigned int size);
// Reserve an aligned memory space from vitaGL mempool
void *gpu_pool_memalign(unsigned int size, unsigned int alignment);
// Returns available free space on vitaGL mempool
unsigned int gpu_pool_free_space();
// Resets vitaGL mempool
void gpu_pool_reset();
// Alloc vitaGL mempool
void gpu_pool_init(uint32_t temp_pool_size);
// Calculate bpp for a requested texture format
int tex_format_to_bytespp(SceGxmTextureFormat format);
// Alloc a texture
void gpu_alloc_texture(uint32_t w, uint32_t h, SceGxmTextureFormat format, const void *data, texture *tex, uint8_t src_bpp, uint32_t (*read_cb)(void *), void (*write_cb)(void *, uint32_t), uint8_t fast_store);
// Alloc a compresseed texture
void gpu_alloc_compressed_texture(uint32_t w, uint32_t h, SceGxmTextureFormat format, uint32_t image_size, const void *data, texture *tex, uint8_t src_bpp, uint32_t (*read_cb)(void *));
// Dealloc a texture
void gpu_free_texture(texture *tex);
// Alloc a palette
palette *gpu_alloc_palette(const void *data, uint32_t w, uint32_t bpe);
// Dealloc a palette
void gpu_free_palette(palette *pal);
// Generate mipmaps for a given texture
void gpu_alloc_mipmaps(int level, texture *tex);
#endif