2016-09-29 19:14:12 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2016-09-29 19:14:12 +00:00
|
|
|
*
|
|
|
|
* 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 <retro_miscellaneous.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2020-02-16 14:10:07 +00:00
|
|
|
#include "../gfx_display.h"
|
2016-09-29 19:14:12 +00:00
|
|
|
|
|
|
|
#include "../../retroarch.h"
|
2020-02-16 14:26:58 +00:00
|
|
|
#include "../font_driver.h"
|
|
|
|
#include "../common/ctr_common.h"
|
|
|
|
#include "../drivers/ctr_gu.h"
|
2017-12-26 02:27:59 +00:00
|
|
|
#include "../../ctr/gpu_old.h"
|
2016-09-29 19:14:12 +00:00
|
|
|
|
2020-02-16 14:10:07 +00:00
|
|
|
static void gfx_display_ctr_draw(gfx_display_ctx_draw_t *draw,
|
2020-03-08 21:05:51 +00:00
|
|
|
void *data, unsigned video_width, unsigned video_height)
|
2016-09-29 19:14:12 +00:00
|
|
|
{
|
2020-09-26 21:31:12 +00:00
|
|
|
ctr_scale_vector_t scale_vector;
|
2020-02-16 14:10:07 +00:00
|
|
|
int colorR, colorG, colorB, colorA;
|
2020-09-26 21:31:12 +00:00
|
|
|
ctr_vertex_t *v = NULL;
|
2018-02-16 16:54:39 +00:00
|
|
|
struct ctr_texture *texture = NULL;
|
|
|
|
const float *color = NULL;
|
2020-03-08 21:05:51 +00:00
|
|
|
ctr_video_t *ctr = (ctr_video_t*)data;
|
2016-09-29 19:14:12 +00:00
|
|
|
|
|
|
|
if (!ctr || !draw)
|
|
|
|
return;
|
|
|
|
|
2017-04-29 17:34:20 +00:00
|
|
|
texture = (struct ctr_texture*)draw->texture;
|
|
|
|
color = draw->coords->color;
|
|
|
|
|
|
|
|
if (!texture)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ctr_set_scale_vector(&scale_vector,
|
|
|
|
CTR_TOP_FRAMEBUFFER_WIDTH, CTR_TOP_FRAMEBUFFER_HEIGHT,
|
|
|
|
texture->width, texture->height);
|
2020-10-28 04:13:19 +00:00
|
|
|
GPUCMD_AddWrite(GPUREG_GSH_BOOLUNIFORM, 0);
|
2017-04-29 17:34:20 +00:00
|
|
|
ctrGuSetVertexShaderFloatUniform(0, (float*)&scale_vector, 1);
|
|
|
|
|
2020-09-26 21:31:12 +00:00
|
|
|
if ((ctr->vertex_cache.size - (ctr->vertex_cache.current
|
|
|
|
- ctr->vertex_cache.buffer)) < 1)
|
2017-04-29 17:34:20 +00:00
|
|
|
ctr->vertex_cache.current = ctr->vertex_cache.buffer;
|
|
|
|
|
2020-09-26 21:31:12 +00:00
|
|
|
v = ctr->vertex_cache.current++;
|
2017-04-29 17:34:20 +00:00
|
|
|
|
|
|
|
v->x0 = draw->x;
|
|
|
|
v->y0 = 240 - draw->height - draw->y;
|
|
|
|
v->x1 = v->x0 + draw->width;
|
|
|
|
v->y1 = v->y0 + draw->height;
|
|
|
|
v->u0 = 0;
|
|
|
|
v->v0 = 0;
|
|
|
|
v->u1 = texture->active_width;
|
|
|
|
v->v1 = texture->active_height;
|
|
|
|
|
|
|
|
ctrGuSetAttributeBuffers(2,
|
|
|
|
VIRT_TO_PHYS(v),
|
|
|
|
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 0 |
|
|
|
|
CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 4,
|
|
|
|
sizeof(ctr_vertex_t));
|
|
|
|
|
2020-02-16 14:10:07 +00:00
|
|
|
color = draw->coords->color;
|
|
|
|
colorR = (int)((*color++)*255.f);
|
|
|
|
colorG = (int)((*color++)*255.f);
|
|
|
|
colorB = (int)((*color++)*255.f);
|
|
|
|
colorA = (int)((*color++)*255.f);
|
2017-04-29 17:34:20 +00:00
|
|
|
|
|
|
|
GPU_SetTexEnv(0,
|
|
|
|
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_CONSTANT, 0),
|
|
|
|
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_CONSTANT, 0),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
GPU_MODULATE, GPU_MODULATE,
|
|
|
|
COLOR_ABGR(colorR,colorG,colorB,colorA)
|
|
|
|
);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
GPU_SetTexEnv(0,
|
|
|
|
GPU_TEVSOURCES(GPU_CONSTANT, GPU_CONSTANT, 0),
|
|
|
|
GPU_TEVSOURCES(GPU_CONSTANT, GPU_CONSTANT, 0),
|
|
|
|
0,
|
|
|
|
GPU_TEVOPERANDS(GPU_TEVOP_RGB_SRC_COLOR, GPU_TEVOP_RGB_SRC_COLOR, 0),
|
|
|
|
GPU_REPLACE, GPU_REPLACE,
|
|
|
|
0x3FFFFFFF);
|
|
|
|
#endif
|
|
|
|
|
2020-09-26 21:51:59 +00:00
|
|
|
ctrGuSetTexture(GPU_TEXUNIT0,
|
|
|
|
VIRT_TO_PHYS(texture->data),
|
|
|
|
texture->width,
|
|
|
|
texture->height,
|
|
|
|
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR)
|
|
|
|
| GPU_TEXTURE_MIN_FILTER(GPU_LINEAR)
|
|
|
|
| GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE)
|
|
|
|
| GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE),
|
2017-04-29 17:34:20 +00:00
|
|
|
GPU_RGBA8);
|
|
|
|
|
|
|
|
GPU_SetViewport(NULL,
|
|
|
|
VIRT_TO_PHYS(ctr->drawbuffers.top.left),
|
|
|
|
0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT,
|
2020-09-26 21:51:59 +00:00
|
|
|
ctr->video_mode == CTR_VIDEO_MODE_2D_800X240
|
|
|
|
? CTR_TOP_FRAMEBUFFER_WIDTH * 2
|
|
|
|
: CTR_TOP_FRAMEBUFFER_WIDTH);
|
2017-04-29 17:34:20 +00:00
|
|
|
|
|
|
|
GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1);
|
|
|
|
|
|
|
|
if (ctr->video_mode == CTR_VIDEO_MODE_3D)
|
|
|
|
{
|
|
|
|
GPU_SetViewport(NULL,
|
|
|
|
VIRT_TO_PHYS(ctr->drawbuffers.top.right),
|
|
|
|
0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT,
|
|
|
|
CTR_TOP_FRAMEBUFFER_WIDTH);
|
|
|
|
GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0);
|
|
|
|
#if 0
|
|
|
|
printf("(%i,%i,%i,%i) , (%i,%i)\n", (int)draw->x,
|
|
|
|
(int)draw->y, (int)draw->width, (int)draw->height,
|
|
|
|
texture->width, texture->height);
|
|
|
|
#endif
|
2016-09-29 19:14:12 +00:00
|
|
|
}
|
|
|
|
|
2020-02-16 14:10:07 +00:00
|
|
|
static bool gfx_display_ctr_font_init_first(
|
2016-09-29 19:14:12 +00:00
|
|
|
void **font_handle, void *video_data,
|
2017-04-29 17:34:20 +00:00
|
|
|
const char *font_path, float font_size,
|
|
|
|
bool is_threaded)
|
2016-09-29 19:14:12 +00:00
|
|
|
{
|
2016-10-18 23:07:00 +00:00
|
|
|
font_data_t **handle = (font_data_t**)font_handle;
|
|
|
|
*handle = font_driver_init_first(video_data,
|
2017-12-12 07:55:31 +00:00
|
|
|
font_path, font_size, true,
|
2017-04-29 17:34:20 +00:00
|
|
|
is_threaded,
|
|
|
|
FONT_DRIVER_RENDER_CTR);
|
2016-10-18 23:07:00 +00:00
|
|
|
return *handle;
|
2016-09-29 19:14:12 +00:00
|
|
|
}
|
|
|
|
|
2020-02-16 14:10:07 +00:00
|
|
|
gfx_display_ctx_driver_t gfx_display_ctx_ctr = {
|
|
|
|
gfx_display_ctr_draw,
|
2020-09-26 21:31:12 +00:00
|
|
|
NULL, /* draw_pipeline */
|
|
|
|
NULL, /* blend_begin */
|
|
|
|
NULL, /* blend_end */
|
2020-09-26 19:40:16 +00:00
|
|
|
NULL, /* get_default_mvp */
|
|
|
|
NULL, /* get_default_vertices */
|
|
|
|
NULL, /* get_default_tex_coords */
|
2020-02-16 14:10:07 +00:00
|
|
|
gfx_display_ctr_font_init_first,
|
|
|
|
GFX_VIDEO_DRIVER_CTR,
|
2018-10-08 23:05:46 +00:00
|
|
|
"ctr",
|
2018-09-20 12:48:07 +00:00
|
|
|
true,
|
|
|
|
NULL,
|
|
|
|
NULL
|
2016-09-29 19:14:12 +00:00
|
|
|
};
|