Merge video_coord_array.c into video_driver.c

pull/15597/head
libretroadmin 2023-08-15 16:02:12 +02:00
parent 40a0ced947
commit 2d2cb04589
19 changed files with 1590 additions and 1652 deletions

View File

@ -321,7 +321,6 @@ OBJ += \
gfx/gfx_animation.o \
gfx/gfx_thumbnail_path.o \
gfx/gfx_thumbnail.o \
gfx/video_coord_array.o \
configuration.o \
$(LIBRETRO_COMM_DIR)/dynamic/dylib.o \
cores/dynamic_dummy.o \

View File

@ -32,7 +32,6 @@
#include <formats/image.h>
#include "../video_driver.h"
#include "../video_coord_array.h"
RETRO_BEGIN_DECLS

View File

@ -33,7 +33,6 @@
#include <formats/image.h>
#include "../video_driver.h"
#include "../video_coord_array.h"
#include "../drivers_shader/shader_gl3.h"
RETRO_BEGIN_DECLS

View File

@ -31,7 +31,6 @@
#include "../../driver.h"
#include "../../retroarch.h"
#include "../video_coord_array.h"
#define RSX_MAX_BUFFERS 2
#define RSX_MAX_MENU_BUFFERS 2

View File

@ -24,9 +24,9 @@
#include <gfx/math/matrix_4x4.h>
#include <defines/psp_defines.h>
#include "../../driver.h"
#include "../../retroarch.h"
#include "../video_coord_array.h"
typedef struct vita_menu_frame
{

View File

@ -41,7 +41,6 @@
#include <defines/d3d_defines.h>
#include "../common/d3d8_defines.h"
#include "../common/d3d_common.h"
#include "../video_coord_array.h"
#include "../../configuration.h"
#include "../../retroarch.h"
#include "../../dynamic.h"
@ -378,7 +377,7 @@ static void d3d8_blit_to_texture(
D3DLOCKED_RECT d3dlr;
D3DLOCKED_RECT *lr = &d3dlr;
LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)chain->dev;
LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)chain->tex;
LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)chain->tex;
#ifdef _XBOX
global_t *global = global_get_ptr();
D3DDevice_SetFlickerFilter(global->console.screen.flicker_filter_index);
@ -483,8 +482,8 @@ static bool d3d8_setup_init(void *data,
video_driver_get_size(&width, &height);
chain->dev = dev_data;
chain->pixel_size = (fmt == RETRO_PIXEL_FORMAT_RGB565)
? 2
chain->pixel_size = (fmt == RETRO_PIXEL_FORMAT_RGB565)
? 2
: 4;
chain->tex_w = link_info->tex_w;
chain->tex_h = link_info->tex_h;
@ -553,7 +552,7 @@ static void *gfx_display_d3d8_get_default_mvp(void *data)
{
static float id[16] = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
return &id;
@ -600,12 +599,12 @@ static void gfx_display_d3d8_blend_end(void *data)
static void gfx_display_d3d8_draw(gfx_display_ctx_draw_t *draw,
void *data,
unsigned video_width,
unsigned video_width,
unsigned video_height)
{
static float default_mvp[] ={ 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
unsigned i;
@ -1912,7 +1911,7 @@ static bool d3d8_frame(void *data, const void *frame,
if (black_frame_insertion && !d3d->menu->enabled)
{
unsigned n;
for (n = 0; n < video_info->black_frame_insertion; ++n)
for (n = 0; n < video_info->black_frame_insertion; ++n)
{
if (IDirect3DDevice8_Present(d3d->dev, NULL, NULL, NULL, NULL)
== D3DERR_DEVICELOST)

View File

@ -48,7 +48,7 @@
#include "../common/d3d9_common.h"
#include "../include/Cg/cg.h"
#include "../include/Cg/cgD3D9.h"
#include "../video_coord_array.h"
#include "../video_driver.h"
#include "../../configuration.h"
#include "../../dynamic.h"
#include "../../frontend/frontend_driver.h"
@ -133,7 +133,7 @@ static void *gfx_display_d3d9_cg_get_default_mvp(void *data)
{
static float id[16] = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
return &id;
@ -263,7 +263,7 @@ static void gfx_display_d3d9_cg_draw(gfx_display_ctx_draw_t *draw,
matrix_4x4_multiply(m1, mop, m2);
matrix_4x4_multiply(m2, d3d->mvp_transposed, m1);
d3d_matrix_transpose(&m1, &m2);
IDirect3DDevice9_SetVertexShaderConstantF(dev,
0, (const float*)&m1, 4);
@ -1657,8 +1657,8 @@ static bool d3d9_cg_init_chain(d3d9_video_t *d3d,
if (!d3d9_renderchain_add_lut(
d3d->renderchain_data,
d3d->shader.lut[i].id, d3d->shader.lut[i].path,
d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC
? video_smooth
d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC
? video_smooth
: (d3d->shader.lut[i].filter == RARCH_FILTER_LINEAR)))
{
RARCH_ERR("[D3D9]: Failed to init LUTs.\n");
@ -1905,7 +1905,7 @@ static bool d3d9_cg_init_internal(d3d9_video_t *d3d,
d3d9_cg_fake_context.get_flags = d3d9_cg_get_flags;
d3d9_cg_fake_context.get_metrics = win32_get_metrics;
video_context_driver_set(&d3d9_cg_fake_context);
video_context_driver_set(&d3d9_cg_fake_context);
{
const char *shader_preset = video_shader_get_current_shader_preset();
enum rarch_shader_type type = video_shader_parse_type(shader_preset);
@ -2087,12 +2087,12 @@ static bool d3d9_cg_frame(void *data, const void *frame,
d3d9_cg_renderchain_render(
d3d, frame, frame_width, frame_height,
pitch, d3d->dev_rotation);
if (black_frame_insertion && !d3d->menu->enabled)
{
int n;
for (n = 0; n < video_info->black_frame_insertion; ++n)
{
for (n = 0; n < video_info->black_frame_insertion; ++n)
{
bool ret = (IDirect3DDevice9_Present(d3d->dev,
NULL, NULL, NULL, NULL) != D3DERR_DEVICELOST);
if (!ret || d3d->needs_restore)
@ -2100,7 +2100,7 @@ static bool d3d9_cg_frame(void *data, const void *frame,
IDirect3DDevice9_Clear(d3d->dev, 0, 0, D3DCLEAR_TARGET,
0, 1, 0);
}
}
}
#ifdef HAVE_OVERLAY
if (d3d->overlays_enabled && overlay_behind_menu)

View File

@ -54,7 +54,7 @@
#include <defines/d3d_defines.h>
#include "../common/d3d_common.h"
#include "../common/d3d9_common.h"
#include "../video_coord_array.h"
#include "../video_driver.h"
#include "../../configuration.h"
#include "../../dynamic.h"
#include "../../frontend/frontend_driver.h"
@ -91,7 +91,7 @@ typedef struct hlsl_renderchain
struct shader_pass stock_shader;
} hlsl_renderchain_t;
/*
/*
* DISPLAY DRIVER
*/
@ -123,7 +123,7 @@ static void *gfx_display_d3d9_hlsl_get_default_mvp(void *data)
{
static float id[16] = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
return &id;
@ -387,7 +387,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d9_hlsl = {
gfx_display_d3d9_hlsl_scissor_end
};
/*
/*
* VIDEO DRIVER
*/
@ -596,7 +596,7 @@ static bool hlsl_d3d9_renderchain_create_first_pass(
int i;
struct shader_pass pass = { 0 };
unsigned fmt =
(_fmt == RETRO_PIXEL_FORMAT_RGB565)
(_fmt == RETRO_PIXEL_FORMAT_RGB565)
? D3D9_RGB565_FORMAT
: D3D9_XRGB8888_FORMAT;
@ -844,8 +844,8 @@ static void hlsl_d3d9_renderchain_render_pass(
struct shader_pass *pass,
unsigned pass_index)
{
/* Currently we override the passes shader program
with the stock shader as at least the last pass
/* Currently we override the passes shader program
with the stock shader as at least the last pass
is not setup correctly */
#if 0
d3d9_hlsl_bind_program(chain->chain.dev, pass);
@ -856,8 +856,8 @@ static void hlsl_d3d9_renderchain_render_pass(
IDirect3DDevice9_SetTexture(chain->chain.dev, 0,
(IDirect3DBaseTexture9*)pass->tex);
/* D3D8 sets the sampler address modes -
I've left them out for the time being
/* D3D8 sets the sampler address modes -
I've left them out for the time being
but maybe this is a bug in d3d9 */
#if 0
IDirect3DDevice9_SetSamplerState(chain->chain.dev,
@ -1019,7 +1019,7 @@ static void hlsl_d3d9_renderchain_render(
chain->chain.frame_count, 0);
hlsl_d3d9_renderchain_render_pass(chain,
from_pass,
from_pass,
i + 1);
current_width = out_width;
@ -1186,7 +1186,7 @@ static bool d3d9_hlsl_init_chain(d3d9_video_t *d3d,
d3d, (hlsl_renderchain_t*)d3d->renderchain_data,
d3d->dev, &d3d->final_viewport, &link_info,
rgb32
? RETRO_PIXEL_FORMAT_XRGB8888
? RETRO_PIXEL_FORMAT_XRGB8888
: RETRO_PIXEL_FORMAT_RGB565
)
)
@ -1234,8 +1234,8 @@ static bool d3d9_hlsl_init_chain(d3d9_video_t *d3d,
chain,
d3d->shader.lut[i].id,
d3d->shader.lut[i].path,
d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC
? video_smooth
d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC
? video_smooth
: (d3d->shader.lut[i].filter == RARCH_FILTER_LINEAR)))
{
RARCH_ERR("[D3D9]: Failed to init LUTs.\n");
@ -1452,10 +1452,10 @@ static bool d3d9_hlsl_init_internal(d3d9_video_t *d3d,
windowed_full = settings->bools.video_windowed_fullscreen;
full_x = (windowed_full || info->width == 0)
? (unsigned)(mon_rect.right - mon_rect.left)
? (unsigned)(mon_rect.right - mon_rect.left)
: info->width;
full_y = (windowed_full || info->height == 0)
? (unsigned)(mon_rect.bottom - mon_rect.top)
? (unsigned)(mon_rect.bottom - mon_rect.top)
: info->height;
#else
d3d9_get_video_size(d3d, &full_x, &full_y);
@ -1488,7 +1488,7 @@ static bool d3d9_hlsl_init_internal(d3d9_video_t *d3d,
#ifndef _XBOX_
d3d9_hlsl_fake_context.get_metrics = win32_get_metrics;
#endif
video_context_driver_set(&d3d9_hlsl_fake_context);
video_context_driver_set(&d3d9_hlsl_fake_context);
{
const char *shader_preset = video_shader_get_current_shader_preset();
enum rarch_shader_type type = video_shader_parse_type(shader_preset);
@ -1673,12 +1673,12 @@ static bool d3d9_hlsl_frame(void *data, const void *frame,
hlsl_d3d9_renderchain_render(
d3d, frame, frame_width, frame_height,
pitch, d3d->dev_rotation);
if (black_frame_insertion && !d3d->menu->enabled)
{
unsigned n;
for (n = 0; n < video_info->black_frame_insertion; ++n)
{
for (n = 0; n < video_info->black_frame_insertion; ++n)
{
#ifdef _XBOX
bool ret = true;
IDirect3DDevice9_Present(d3d->dev, NULL, NULL, NULL, NULL);
@ -1691,7 +1691,7 @@ static bool d3d9_hlsl_frame(void *data, const void *frame,
IDirect3DDevice9_Clear(d3d->dev, 0, 0, D3DCLEAR_TARGET,
0, 1, 0);
}
}
}
#ifdef HAVE_OVERLAY
if (d3d->overlays_enabled && overlay_behind_menu)

View File

@ -48,6 +48,7 @@
#endif
#include "../font_driver.h"
#include "../video_driver.h"
#include "../common/metal_common.h"
@ -60,8 +61,6 @@
#endif
#include "../../verbosity.h"
#include "../video_coord_array.h"
#include "../../ui/drivers/cocoa/apple_platform.h"
#include "../../ui/drivers/cocoa/cocoa_common.h"

View File

@ -33,10 +33,10 @@
#endif
#include "../font_driver.h"
#include "../video_driver.h"
#include "../common/vita2d_defines.h"
#include "../../driver.h"
#include "../video_coord_array.h"
#include "../../verbosity.h"
#include "../../configuration.h"
@ -149,7 +149,7 @@ static void gfx_display_vita2d_draw(gfx_display_ctx_draw_t *draw,
vertices[i].z = 1.0f;
vertices[i].u = *tex_coord++;
vertices[i].v = *tex_coord++;
vertices[i].r = *color++;
vertices[i].r = *color++;
vertices[i].g = *color++;
vertices[i].b = *color++;
vertices[i].a = *color++;
@ -164,7 +164,7 @@ static void gfx_display_vita2d_scissor_begin(void *data,
int x, int y,
unsigned width, unsigned height)
{
vita2d_set_clip_rectangle(x, y, x + width, y + 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);
}
@ -546,7 +546,7 @@ static void *vita2d_gfx_init(const video_info_t *video,
*input = NULL;
*input_data = NULL;
vita2d_init_advanced_with_msaa((1 * 1024 * 1024), SCE_GXM_MULTISAMPLE_4X,
vita2d_init_advanced_with_msaa((1 * 1024 * 1024), SCE_GXM_MULTISAMPLE_4X,
sceKernelGetModelForCDialog() == SCE_KERNEL_MODEL_VITATV? VITA2D_VIDEO_MODE_1280x720 : VITA2D_VIDEO_MODE_960x544 );
vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
vita2d_set_vblank_wait(video->vsync);
@ -635,7 +635,7 @@ static bool vita2d_frame(void *data, const void *frame,
bool widgets_active = video_info->widgets_active;
#endif
bool statistics_show = video_info->statistics_show;
struct font_params
struct font_params
*osd_params = (struct font_params*)
&video_info->osd_stat_params;
@ -849,7 +849,7 @@ static void vita2d_set_projection(vita_video_t *vita,
static void vita2d_update_viewport(vita_video_t* vita,
video_frame_info_t *video_info)
{
vita2d_video_mode_data
vita2d_video_mode_data
video_mode_data = vita2d_get_video_mode_data();
unsigned temp_width = video_mode_data.width;
unsigned temp_height = video_mode_data.height;
@ -1058,7 +1058,7 @@ static void vita2d_set_filtering(void *data, unsigned index, bool smooth, bool c
if (vita)
{
vita->tex_filter = smooth
? SCE_GXM_TEXTURE_FILTER_LINEAR
? SCE_GXM_TEXTURE_FILTER_LINEAR
: SCE_GXM_TEXTURE_FILTER_POINT;
vita2d_texture_set_filters(vita->texture,vita->tex_filter,
vita->tex_filter);
@ -1183,7 +1183,7 @@ static uintptr_t vita2d_load_texture(void *video_data, void *data,
return (uintptr_t)texture;
}
static void vita2d_unload_texture(void *data,
static void vita2d_unload_texture(void *data,
bool threaded, uintptr_t handle)
{
struct vita2d_texture *texture = (struct vita2d_texture*)handle;
@ -1205,7 +1205,7 @@ static bool vita2d_get_current_sw_framebuffer(void *data,
{
vita_video_t *vita = (vita_video_t*)data;
if ( !vita->texture
if ( !vita->texture
|| (vita->width != framebuffer->width)
|| (vita->height != framebuffer->height))
{
@ -1227,7 +1227,7 @@ static bool vita2d_get_current_sw_framebuffer(void *data,
framebuffer->data = vita2d_texture_get_datap(vita->texture);
framebuffer->pitch = vita2d_texture_get_stride(vita->texture);
framebuffer->format = vita->rgb32
? RETRO_PIXEL_FORMAT_XRGB8888
? RETRO_PIXEL_FORMAT_XRGB8888
: RETRO_PIXEL_FORMAT_RGB565;
framebuffer->memory_flags = 0;

View File

@ -42,6 +42,7 @@
#endif
#include "../font_driver.h"
#include "../video_driver.h"
#include "../common/vulkan_common.h"
@ -50,11 +51,9 @@
#include "../../state_manager.h"
#endif
#include "../../record/record_driver.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../record/record_driver.h"
#include "../video_coord_array.h"
#define VK_REMAP_TO_TEXFMT(fmt) ((fmt == VK_FORMAT_R5G6B5_UNORM_PACK16) ? VK_FORMAT_R8G8B8A8_UNORM : fmt)

View File

@ -16,7 +16,6 @@
*/
#include "gfx_display.h"
#include "video_coord_array.h"
#include "../configuration.h"
#include "../verbosity.h"
@ -208,7 +207,7 @@ static float gfx_display_get_dpi_scale_internal(
fraction -= 24.0f;
fraction /= (32.0f - 24.0f);
scale = ((1.0f - fraction) * dpi_scale)
scale = ((1.0f - fraction) * dpi_scale)
+ (fraction * pixel_scale);
}
else if (display_size < 12.0f)
@ -224,7 +223,7 @@ static float gfx_display_get_dpi_scale_internal(
* to pixel scaling */
float fraction = display_size / 12.0f;
scale = ((1.0f - fraction) * pixel_scale)
scale = ((1.0f - fraction) * pixel_scale)
+ (fraction * dpi_scale);
}
else
@ -269,7 +268,7 @@ float gfx_display_get_dpi_scale(
float menu_widget_scale_factor = fullscreen ?
menu_widget_scale_factor_fullscreen : menu_widget_scale_factor_windowed;
#endif
float menu_scale_factor = is_widget
float menu_scale_factor = is_widget
? menu_widget_scale_factor
: settings->floats.menu_scale_factor;
#else
@ -507,7 +506,7 @@ void gfx_display_draw_quad(
{
gfx_display_ctx_draw_t draw;
struct video_coords coords;
gfx_display_ctx_driver_t
gfx_display_ctx_driver_t
*dispctx = p_disp->dispctx;
if (w == 0 || h == 0)
@ -527,8 +526,8 @@ void gfx_display_draw_quad(
draw.height = h;
draw.coords = &coords;
draw.matrix_data = NULL;
draw.texture = (texture != 0)
? *texture
draw.texture = (texture != 0)
? *texture
: gfx_white_texture;
draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
draw.pipeline_id = 0;
@ -560,7 +559,7 @@ void gfx_display_draw_texture_slice(
{
gfx_display_ctx_draw_t draw;
struct video_coords coords;
gfx_display_ctx_driver_t
gfx_display_ctx_driver_t
*dispctx = p_disp->dispctx;
float V_BL[2], V_BR[2], V_TL[2], V_TR[2], T_BL[2], T_BR[2], T_TL[2], T_TR[2];
/* To prevent visible seams between the corners and
@ -607,7 +606,7 @@ void gfx_display_draw_texture_slice(
* so 8 vertices */
float tex_coord[8];
float vert_coord[8];
static float colors[16] = {
static float colors[16] = {
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
@ -878,7 +877,7 @@ void gfx_display_rotate_z(gfx_display_t *p_disp,
math_matrix_4x4 *matrix, float cosine, float sine, void *data)
{
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
math_matrix_4x4 *b = (dispctx->get_default_mvp)
math_matrix_4x4 *b = (dispctx->get_default_mvp)
? (math_matrix_4x4*)dispctx->get_default_mvp(data)
: NULL;
if (b)
@ -887,7 +886,7 @@ void gfx_display_rotate_z(gfx_display_t *p_disp,
{ 0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 1.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 1.0f }
0.0f, 0.0f, 0.0f, 1.0f }
};
MAT_ELEM_4X4(rot, 0, 0) = cosine;
MAT_ELEM_4X4(rot, 0, 1) = -sine;
@ -1082,7 +1081,7 @@ bool gfx_display_reset_textures_list_buffer(
if (height)
*height = ti.height;
/* if the poke interface doesn't support texture load then return false */
/* if the poke interface doesn't support texture load then return false */
if (video_driver_texture_load(&ti, filter_type, item))
{
image_texture_free(&ti);

View File

@ -1,120 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <retro_inline.h>
#include <retro_math.h>
#include "video_coord_array.h"
static INLINE bool realloc_checked(void **ptr, size_t size)
{
void *nptr = NULL;
if (*ptr)
nptr = realloc(*ptr, size);
else
nptr = malloc(size);
if (nptr)
*ptr = nptr;
return *ptr == nptr;
}
static bool video_coord_array_resize(video_coord_array_t *ca,
unsigned cap)
{
size_t base_size = sizeof(float) * cap;
if (!realloc_checked((void**)&ca->coords.vertex,
2 * base_size))
return false;
if (!realloc_checked((void**)&ca->coords.color,
4 * base_size))
return false;
if (!realloc_checked((void**)&ca->coords.tex_coord,
2 * base_size))
return false;
if (!realloc_checked((void**)&ca->coords.lut_tex_coord,
2 * base_size))
return false;
ca->allocated = cap;
return true;
}
bool video_coord_array_append(video_coord_array_t *ca,
const video_coords_t *coords, unsigned count)
{
size_t base_size, offset;
count = MIN(count, coords->vertices);
if (ca->coords.vertices + count >= ca->allocated)
{
unsigned cap = next_pow2(ca->coords.vertices + count);
if (!video_coord_array_resize(ca, cap))
return false;
}
base_size = count * sizeof(float);
offset = ca->coords.vertices;
/* XXX: I wish we used interlaced arrays so
* we could call memcpy only once. */
memcpy(ca->coords.vertex + offset * 2,
coords->vertex, base_size * 2);
memcpy(ca->coords.color + offset * 4,
coords->color, base_size * 4);
memcpy(ca->coords.tex_coord + offset * 2,
coords->tex_coord, base_size * 2);
memcpy(ca->coords.lut_tex_coord + offset * 2,
coords->lut_tex_coord, base_size * 2);
ca->coords.vertices += count;
return true;
}
void video_coord_array_free(video_coord_array_t *ca)
{
if (!ca->allocated)
return;
if (ca->coords.vertex)
free(ca->coords.vertex);
ca->coords.vertex = NULL;
if (ca->coords.color)
free(ca->coords.color);
ca->coords.color = NULL;
if (ca->coords.tex_coord)
free(ca->coords.tex_coord);
ca->coords.tex_coord = NULL;
if (ca->coords.lut_tex_coord)
free(ca->coords.lut_tex_coord);
ca->coords.lut_tex_coord = NULL;
ca->coords.vertices = 0;
ca->allocated = 0;
}

View File

@ -1,97 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* copyright (c) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VIDEO_COORD_ARRAY_H
#define __VIDEO_COORD_ARRAY_H
#include <stdint.h>
#include <string.h>
#include <boolean.h>
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
struct video_fbo_rect
{
unsigned img_width;
unsigned img_height;
unsigned max_img_width;
unsigned max_img_height;
unsigned width;
unsigned height;
};
struct video_ortho
{
float left;
float right;
float bottom;
float top;
float znear;
float zfar;
};
struct video_tex_info
{
unsigned int tex;
float input_size[2];
float tex_size[2];
float coord[8];
};
typedef struct video_coords
{
const float *vertex;
const float *color;
const float *tex_coord;
const float *lut_tex_coord;
const unsigned *index;
unsigned vertices;
unsigned indexes;
} video_coords_t;
typedef struct video_mut_coords
{
float *vertex;
float *color;
float *tex_coord;
float *lut_tex_coord;
unsigned *index;
unsigned vertices;
unsigned indexes;
} video_mut_coords_t;
typedef struct video_coord_array
{
video_mut_coords_t coords; /* ptr alignment */
unsigned allocated;
} video_coord_array_t;
typedef struct video_font_raster_block
{
video_coord_array_t carr; /* ptr alignment */
bool fullscreen;
} video_font_raster_block_t;
bool video_coord_array_append(video_coord_array_t *ca,
const video_coords_t *coords, unsigned count);
void video_coord_array_free(video_coord_array_t *ca);
RETRO_END_DECLS
#endif

View File

@ -315,6 +315,69 @@ struct font_line_metrics
float descender;
};
struct video_fbo_rect
{
unsigned img_width;
unsigned img_height;
unsigned max_img_width;
unsigned max_img_height;
unsigned width;
unsigned height;
};
struct video_ortho
{
float left;
float right;
float bottom;
float top;
float znear;
float zfar;
};
struct video_tex_info
{
unsigned int tex;
float input_size[2];
float tex_size[2];
float coord[8];
};
typedef struct video_coords
{
const float *vertex;
const float *color;
const float *tex_coord;
const float *lut_tex_coord;
const unsigned *index;
unsigned vertices;
unsigned indexes;
} video_coords_t;
typedef struct video_mut_coords
{
float *vertex;
float *color;
float *tex_coord;
float *lut_tex_coord;
unsigned *index;
unsigned vertices;
unsigned indexes;
} video_mut_coords_t;
typedef struct video_coord_array
{
video_mut_coords_t coords; /* ptr alignment */
unsigned allocated;
} video_coord_array_t;
typedef struct video_font_raster_block
{
video_coord_array_t carr; /* ptr alignment */
bool fullscreen;
} video_font_raster_block_t;
RETRO_END_DECLS
#endif

View File

@ -14,7 +14,10 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <math.h>
#include <retro_inline.h>
#include <string/stdstring.h>
#include <retro_math.h>
@ -194,6 +197,104 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ 4.0f / 3.0f , "" } /* full - initialized in video_driver_init_internal */
};
static INLINE bool realloc_checked(void **ptr, size_t size)
{
void *nptr = NULL;
if (*ptr)
nptr = realloc(*ptr, size);
else
nptr = malloc(size);
if (nptr)
*ptr = nptr;
return *ptr == nptr;
}
static bool video_coord_array_resize(video_coord_array_t *ca,
unsigned cap)
{
size_t base_size = sizeof(float) * cap;
if (!realloc_checked((void**)&ca->coords.vertex,
2 * base_size))
return false;
if (!realloc_checked((void**)&ca->coords.color,
4 * base_size))
return false;
if (!realloc_checked((void**)&ca->coords.tex_coord,
2 * base_size))
return false;
if (!realloc_checked((void**)&ca->coords.lut_tex_coord,
2 * base_size))
return false;
ca->allocated = cap;
return true;
}
bool video_coord_array_append(video_coord_array_t *ca,
const video_coords_t *coords, unsigned count)
{
size_t base_size, offset;
count = MIN(count, coords->vertices);
if (ca->coords.vertices + count >= ca->allocated)
{
unsigned cap = next_pow2(ca->coords.vertices + count);
if (!video_coord_array_resize(ca, cap))
return false;
}
base_size = count * sizeof(float);
offset = ca->coords.vertices;
/* XXX: I wish we used interlaced arrays so
* we could call memcpy only once. */
memcpy(ca->coords.vertex + offset * 2,
coords->vertex, base_size * 2);
memcpy(ca->coords.color + offset * 4,
coords->color, base_size * 4);
memcpy(ca->coords.tex_coord + offset * 2,
coords->tex_coord, base_size * 2);
memcpy(ca->coords.lut_tex_coord + offset * 2,
coords->lut_tex_coord, base_size * 2);
ca->coords.vertices += count;
return true;
}
void video_coord_array_free(video_coord_array_t *ca)
{
if (!ca->allocated)
return;
if (ca->coords.vertex)
free(ca->coords.vertex);
ca->coords.vertex = NULL;
if (ca->coords.color)
free(ca->coords.color);
ca->coords.color = NULL;
if (ca->coords.tex_coord)
free(ca->coords.tex_coord);
ca->coords.tex_coord = NULL;
if (ca->coords.lut_tex_coord)
free(ca->coords.lut_tex_coord);
ca->coords.lut_tex_coord = NULL;
ca->coords.vertices = 0;
ca->allocated = 0;
}
static void *video_null_init(const video_info_t *video,
input_driver_t **input, void **input_data)
{
@ -3467,7 +3568,7 @@ void video_driver_frame(const void *data, unsigned width,
last_fps = TIME_TO_FPS(curr_time, new_time,
fps_update_interval);
new_len = strlcpy(video_st->window_title, video_st->title_buf,
new_len = strlcpy(video_st->window_title, video_st->title_buf,
sizeof(video_st->window_title));
if (!string_is_empty(status_text))

File diff suppressed because it is too large Load Diff

View File

@ -938,7 +938,6 @@ DRIVERS
#include "../gfx/gfx_display.c"
#include "../gfx/gfx_thumbnail_path.c"
#include "../gfx/gfx_thumbnail.c"
#include "../gfx/video_coord_array.c"
#ifdef HAVE_AUDIOMIXER
#include "../libretro-common/audio/audio_mixer.c"
#endif

View File

@ -388,7 +388,6 @@
05A8C67720DB72F000FF7857 /* video_crt_switch.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = video_crt_switch.c; sourceTree = "<group>"; };
05A8C70E20DB72F000FF7857 /* video_shader_parse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = video_shader_parse.h; sourceTree = "<group>"; };
05A8C71320DB72F000FF7857 /* video_filter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = video_filter.h; sourceTree = "<group>"; };
05A8C73820DB72F100FF7857 /* video_coord_array.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = video_coord_array.h; sourceTree = "<group>"; };
05A8C73920DB72F100FF7857 /* font_driver.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = font_driver.c; sourceTree = "<group>"; };
05A8C73C20DB72F100FF7857 /* vulkan_common.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vulkan_common.c; sourceTree = "<group>"; };
05A8C74420DB72F100FF7857 /* metal_common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = metal_common.h; sourceTree = "<group>"; };
@ -427,7 +426,6 @@
05A8C7A020DB72F100FF7857 /* video_thread_wrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = video_thread_wrapper.h; sourceTree = "<group>"; };
05A8C7A720DB72F100FF7857 /* font_driver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = font_driver.h; sourceTree = "<group>"; };
05A8C7A820DB72F100FF7857 /* video_defines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = video_defines.h; sourceTree = "<group>"; };
05A8C7A920DB72F100FF7857 /* video_coord_array.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = video_coord_array.c; sourceTree = "<group>"; };
05A8C7AB20DB72F100FF7857 /* freetype.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = freetype.c; sourceTree = "<group>"; };
05A8C7AC20DB72F100FF7857 /* bitmap.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = bitmap.bmp; sourceTree = "<group>"; };
05A8C7AD20DB72F100FF7857 /* coretext.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = coretext.c; sourceTree = "<group>"; };
@ -982,8 +980,6 @@
05A8C78E20DB72F100FF7857 /* drivers_shader */,
05A8C73920DB72F100FF7857 /* font_driver.c */,
05A8C7A720DB72F100FF7857 /* font_driver.h */,
05A8C7A920DB72F100FF7857 /* video_coord_array.c */,
05A8C73820DB72F100FF7857 /* video_coord_array.h */,
05A8C67720DB72F000FF7857 /* video_crt_switch.c */,
05A8C79D20DB72F100FF7857 /* video_crt_switch.h */,
05A8C7A820DB72F100FF7857 /* video_defines.h */,