This commit is contained in:
libretroadmin 2023-06-01 21:34:34 +02:00
parent f3fe46393c
commit c1166ee823
28 changed files with 942 additions and 961 deletions

View File

@ -36,6 +36,13 @@
#include "../../driver.h"
#include "../../verbosity.h"
typedef struct
{
const font_renderer_driver_t *font_driver;
void *font_data;
caca_t *caca;
} caca_raster_t;
/*
* FORWARD DECLARATIONS
*/
@ -45,13 +52,6 @@ static void caca_free(void *data);
* FONT DRIVER
*/
typedef struct
{
const font_renderer_driver_t *font_driver;
void *font_data;
caca_t *caca;
} caca_raster_t;
static void *caca_font_init(void *data,
const char *font_path, float font_size,
bool is_threaded)

View File

@ -55,6 +55,46 @@
#include "../../tasks/tasks_internal.h"
#endif
enum
{
CTR_TEXTURE_BOTTOM_MENU = 0,
CTR_TEXTURE_STATE_THUMBNAIL,
CTR_TEXTURE_LAST
};
struct ctr_bottom_texture_data
{
uintptr_t texture;
ctr_vertex_t* frame_coords;
ctr_scale_vector_t scale_vector;
};
typedef struct
{
ctr_texture_t texture;
ctr_scale_vector_t scale_vector_top;
ctr_scale_vector_t scale_vector_bottom;
const font_renderer_driver_t* font_driver;
void* font_data;
} ctr_font_t;
/* An annoyance...
* Have to keep track of bottom screen enable state
* externally, otherwise cannot detect current state
* when reinitialising... */
static bool ctr_bottom_screen_enabled = true;
static int fade_count = 256;
/*
* FORWARD DECLARATIONS
*/
/* TODO/FIXME - global referenced outside */
extern uint64_t lifecycle_state;
static void ctr_set_bottom_screen_enable(bool enabled, bool idle);
/*
* DISPLAY DRIVER
*/
@ -186,15 +226,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_ctr = {
* FONT DRIVER
*/
typedef struct
{
ctr_texture_t texture;
ctr_scale_vector_t scale_vector_top;
ctr_scale_vector_t scale_vector_bottom;
const font_renderer_driver_t* font_driver;
void* font_data;
} ctr_font_t;
static void* ctr_font_init(void* data, const char* font_path,
float font_size, bool is_threaded)
{
@ -614,32 +645,6 @@ font_renderer_t ctr_font =
* VIDEO DRIVER
*/
enum
{
CTR_TEXTURE_BOTTOM_MENU,
CTR_TEXTURE_STATE_THUMBNAIL,
CTR_TEXTURE_LAST
};
struct ctr_bottom_texture_data
{
uintptr_t texture;
ctr_vertex_t* frame_coords;
ctr_scale_vector_t scale_vector;
};
/* TODO/FIXME - global referenced outside */
extern uint64_t lifecycle_state;
/* An annoyance...
* Have to keep track of bottom screen enable state
* externally, otherwise cannot detect current state
* when reinitialising... */
static bool ctr_bottom_screen_enabled = true;
static int fade_count = 256;
static void ctr_set_bottom_screen_enable(bool enabled, bool idle);
static INLINE void ctr_check_3D_slider(ctr_video_t* ctr, ctr_video_mode_enum video_mode)
{
float slider_val = *(float*)0x1FF81080;
@ -2873,10 +2878,9 @@ static void ctr_overlay_full_screen(void *data, bool enable)
static void ctr_overlay_set_alpha(void *data, unsigned image, float mod){ }
static void ctr_render_overlay(void *data)
static void ctr_render_overlay(ctr_video_t *ctr)
{
int i;
ctr_video_t *ctr = (ctr_video_t*)data;
for (i = 0; i < ctr->overlays; i++)
{

View File

@ -60,6 +60,18 @@
#error "UWP does not support D3D10"
#endif
typedef struct
{
d3d10_texture_t texture;
const font_renderer_driver_t* font_driver;
void* font_data;
struct font_atlas* atlas;
} d3d10_font_t;
/* Temporary workaround for d3d10 not being able to poll flags during init */
static gfx_ctx_driver_t d3d10_fake_context;
static uint32_t d3d10_get_flags(void *data);
/*
* D3D10 COMMON
*/
@ -566,14 +578,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d10 = {
* FONT DRIVER
*/
typedef struct
{
d3d10_texture_t texture;
const font_renderer_driver_t* font_driver;
void* font_data;
struct font_atlas* atlas;
} d3d10_font_t;
static void *d3d10_font_init(void* data, const char* font_path,
float font_size, bool is_threaded)
{
@ -932,23 +936,6 @@ font_renderer_t d3d10_font = {
* VIDEO DRIVER
*/
/* Temporary workaround for d3d10 not being able to poll flags during init */
static gfx_ctx_driver_t d3d10_fake_context;
static uint32_t d3d10_get_flags(void *data);
static void d3d10_clear_scissor(d3d10_video_t *d3d10, unsigned width, unsigned height)
{
D3D10_RECT scissor_rect;
scissor_rect.left = 0;
scissor_rect.top = 0;
scissor_rect.right = width;
scissor_rect.bottom = height;
d3d10->device->lpVtbl->RSSetScissorRects(d3d10->device, 1,
&scissor_rect);
}
#ifdef HAVE_OVERLAY
static void d3d10_free_overlays(d3d10_video_t* d3d10)
{
@ -959,7 +946,7 @@ static void d3d10_free_overlays(d3d10_video_t* d3d10)
Release(d3d10->overlays.vbo);
}
static void
static void
d3d10_overlay_vertex_geom(void* data, unsigned index, float x, float y, float w, float h)
{
d3d10_sprite_t* sprites = NULL;
@ -2406,7 +2393,17 @@ static bool d3d10_gfx_frame(
d3d10->clearcolor);
context->lpVtbl->RSSetViewports(context, 1, &d3d10->frame.viewport);
d3d10_clear_scissor(d3d10, video_width, video_height);
{
D3D10_RECT scissor_rect;
scissor_rect.left = 0;
scissor_rect.top = 0;
scissor_rect.right = video_width;
scissor_rect.bottom = video_height;
d3d10->device->lpVtbl->RSSetScissorRects(d3d10->device, 1,
&scissor_rect);
}
context->lpVtbl->Draw(context, 4, 0);
context->lpVtbl->OMSetBlendState(context, d3d10->blend_enable, NULL,

View File

@ -76,6 +76,13 @@ const GUID DECLSPEC_SELECTANY libretro_IID_IDXGIFactory5 = { 0x7632e1f5,0xee65,0
#endif
#endif
/* Temporary workaround for d3d11 not being able to poll flags during init */
static gfx_ctx_driver_t d3d11_fake_context;
static D3D11Device cached_device_d3d11;
static D3D_FEATURE_LEVEL cached_supportedFeatureLevel;
static D3D11DeviceContext cached_context_d3d11;
/*
* D3D11 COMMON
*/
@ -983,13 +990,6 @@ font_renderer_t d3d11_font = {
* VIDEO DRIVER
*/
/* Temporary workaround for d3d11 not being able to poll flags during init */
static gfx_ctx_driver_t d3d11_fake_context;
static D3D11Device cached_device_d3d11;
static D3D_FEATURE_LEVEL cached_supportedFeatureLevel;
static D3D11DeviceContext cached_context_d3d11;
static INLINE void d3d11_release_shader(d3d11_shader_t* shader)
{
Release(shader->layout);

View File

@ -68,6 +68,54 @@
#include "../../uwp/uwp_func.h"
#endif
#define D3D12_GFX_SYNC() \
{ \
D3D12Fence fence = d3d12->queue.fence; \
d3d12->queue.handle->lpVtbl->Signal(d3d12->queue.handle, fence, ++d3d12->queue.fenceValue); \
if (fence->lpVtbl->GetCompletedValue(fence) < d3d12->queue.fenceValue) \
{ \
fence->lpVtbl->SetEventOnCompletion(fence, d3d12->queue.fenceValue, d3d12->queue.fenceEvent); \
WaitForSingleObject(d3d12->queue.fenceEvent, INFINITE); \
} \
}
typedef struct
{
d3d12_texture_t texture;
const font_renderer_driver_t* font_driver;
void* font_data;
struct font_atlas* atlas;
} d3d12_font_t;
static D3D12_RENDER_TARGET_BLEND_DESC d3d12_blend_enable_desc = {
TRUE,
FALSE,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_LOGIC_OP_NOOP,
D3D12_COLOR_WRITE_ENABLE_ALL,
};
static D3D12_RENDER_TARGET_BLEND_DESC d3d12_blend_disable_desc = {
FALSE,
FALSE,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_LOGIC_OP_NOOP,
D3D12_COLOR_WRITE_ENABLE_ALL,
};
/* Temporary workaround for d3d12 not being able to poll flags during init */
static gfx_ctx_driver_t d3d12_fake_context;
/*
* D3D12 COMMON
*/
@ -639,7 +687,7 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw,
d3d12->ubo_view.BufferLocation);
}
void gfx_display_d3d12_scissor_begin(void *data,
static void gfx_display_d3d12_scissor_begin(void *data,
unsigned video_width, unsigned video_height,
int x, int y, unsigned width, unsigned height)
{
@ -660,7 +708,7 @@ void gfx_display_d3d12_scissor_begin(void *data,
cmd->lpVtbl->RSSetScissorRects(cmd, 1, &rect);
}
void gfx_display_d3d12_scissor_end(void *data,
static void gfx_display_d3d12_scissor_end(void *data,
unsigned video_width,
unsigned video_height)
{
@ -701,14 +749,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d12 = {
* FONT DRIVER
*/
typedef struct
{
d3d12_texture_t texture;
const font_renderer_driver_t* font_driver;
void* font_data;
struct font_atlas* atlas;
} d3d12_font_t;
static void * d3d12_font_init(void* data, const char* font_path,
float font_size, bool is_threaded)
{
@ -1078,46 +1118,6 @@ font_renderer_t d3d12_font = {
* VIDEO DRIVER
*/
static D3D12_RENDER_TARGET_BLEND_DESC d3d12_blend_enable_desc = {
TRUE,
FALSE,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_LOGIC_OP_NOOP,
D3D12_COLOR_WRITE_ENABLE_ALL,
};
static D3D12_RENDER_TARGET_BLEND_DESC d3d12_blend_disable_desc = {
FALSE,
FALSE,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_BLEND_SRC_ALPHA,
D3D12_BLEND_INV_SRC_ALPHA,
D3D12_BLEND_OP_ADD,
D3D12_LOGIC_OP_NOOP,
D3D12_COLOR_WRITE_ENABLE_ALL,
};
#define D3D12_GFX_SYNC() \
{ \
D3D12Fence fence = d3d12->queue.fence; \
d3d12->queue.handle->lpVtbl->Signal(d3d12->queue.handle, fence, ++d3d12->queue.fenceValue); \
if (fence->lpVtbl->GetCompletedValue(fence) < d3d12->queue.fenceValue) \
{ \
fence->lpVtbl->SetEventOnCompletion(fence, d3d12->queue.fenceValue, d3d12->queue.fenceEvent); \
WaitForSingleObject(d3d12->queue.fenceEvent, INFINITE); \
} \
}
/* Temporary workaround for d3d12 not being able to poll flags during init */
static gfx_ctx_driver_t d3d12_fake_context;
static uint32_t d3d12_get_flags(void *data)
{
uint32_t flags = 0;

View File

@ -80,10 +80,6 @@
#define D3D8_ARGB8888_FORMAT D3DFMT_A8R8G8B8
#endif
static LPDIRECT3D8 g_pD3D8;
void *dinput;
typedef struct d3d8_renderchain
{
unsigned pixel_size;
@ -106,6 +102,24 @@ struct d3d8_texture_info
enum texture_filter_type type;
};
static const float d3d8_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const float d3d8_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static LPDIRECT3D8 g_pD3D8;
void *dinput;
/*
* D3D8 COMMON
*/
@ -525,20 +539,6 @@ static void *d3d8_renderchain_new(void)
* DISPLAY DRIVER
*/
static const float d3d8_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const float d3d8_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const float *gfx_display_d3d8_get_default_vertices(void)
{
return &d3d8_vertexes[0];

View File

@ -437,16 +437,16 @@ static INLINE CGparameter d3d9_cg_find_param_from_semantic(
return ret;
}
if ( cgGetParameterDirection(param) != CG_IN
|| cgGetParameterVariability(param) != CG_VARYING)
if ( (cgGetParameterDirection(param) != CG_IN)
|| (cgGetParameterVariability(param) != CG_VARYING))
continue;
semantic = cgGetParameterSemantic(param);
if (!semantic)
continue;
if (string_is_equal(sem, semantic) &&
d3d9_cg_validate_param_name(cgGetParameterName(param)))
if ( string_is_equal(sem, semantic)
&& d3d9_cg_validate_param_name(cgGetParameterName(param)))
return param;
}
@ -467,8 +467,8 @@ static bool d3d9_cg_load_program(cg_renderchain_t *chain,
CGcontext cgCtx = chain->cgCtx;
if (
fragment_profile == CG_PROFILE_UNKNOWN ||
vertex_profile == CG_PROFILE_UNKNOWN)
(fragment_profile == CG_PROFILE_UNKNOWN)
|| (vertex_profile == CG_PROFILE_UNKNOWN))
{
RARCH_ERR("Invalid profile type\n");
goto error;

View File

@ -85,32 +85,18 @@ struct dispmanx_video
{
DISPMANX_DISPLAY_HANDLE_T display;
DISPMANX_UPDATE_HANDLE_T update;
uint32_t vc_image_ptr;
struct dispmanx_surface *main_surface;
struct dispmanx_surface *menu_surface;
struct dispmanx_surface *back_surface;
/* For console blanking */
int fb_fd;
uint8_t *fb_addr;
unsigned int screensize;
uint8_t *screen_bck;
/* Total dispmanx video dimensions. Not counting overscan settings. */
unsigned int dispmanx_width;
unsigned int dispmanx_height;
/* For threading */
scond_t *vsync_condition;
slock_t *pending_mutex;
unsigned int pageflip_pending;
/* Menu */
bool menu_active;
bool rgb32;
/* We use this to keep track of internal resolution changes
* done by cores in the main surface or in the menu.
* We need these outside the surface because we free surfaces
@ -122,9 +108,23 @@ struct dispmanx_video
int menu_width;
int menu_height;
int menu_pitch;
int fb_fd; /* For console blanking */
unsigned int screensize; /* For console blanking */
/* Total dispmanx video dimensions. Not counting overscan settings. */
unsigned int dispmanx_width;
unsigned int dispmanx_height;
unsigned int pageflip_pending; /* For threading */
uint32_t vc_image_ptr;
/* Both main and menu surfaces are going to have the same aspect,
* so we keep it here for future reference. */
float aspect_ratio;
/* Menu */
bool menu_active;
bool rgb32;
};
/* If no free page is available when called, wait for a page flip. */

View File

@ -64,7 +64,7 @@ enum exynos_buffer_type
/* We have to handle three types of 'data' from the frontend, each abstracted by a *
* G2D image object. The image objects are then backed by some storage buffer. *
* (1) the core framebuffer (backed by main buffer) *
* (1) the core framebuffer (backed by main buffer) *
* (2) the menu buffer (backed by aux buffer) *
* (3) the font rendering buffer (backed by aux buffer) */
enum exynos_image_type

View File

@ -64,9 +64,86 @@
#ifdef VITA
#include <defines/psp_defines.h>
static bool vgl_inited = false;
#endif
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define GL1_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define IS_POT(x) (((x) & (x - 1)) == 0)
#define GET_POT(x) (IS_POT((x)) ? (x) : next_pow2((x)))
#define MAX_MSG_LEN_CHUNK 64
typedef struct
{
gl1_t *gl;
GLuint tex;
unsigned tex_width, tex_height;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
video_font_raster_block_t *block;
} gl1_raster_t;
static const GLfloat gl1_menu_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl1_menu_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static struct video_ortho gl1_default_ortho = {0, 1, 0, 1, -1, 1};
/* Used for the last pass when rendering to the back buffer. */
static const GLfloat gl1_vertexes_flipped[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const GLfloat gl1_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl1_tex_coords[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl1_white_color[16] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
};
/**
* FORWARD DECLARATIONS
*/
@ -79,20 +156,6 @@ static void gl1_set_viewport(gl1_t *gl1,
* DISPLAY DRIVER
*/
static const GLfloat gl1_menu_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl1_menu_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const float *gfx_display_gl1_get_default_vertices(void)
{
return &gl1_menu_vertexes[0];
@ -260,36 +323,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_gl1 = {
* FONT DRIVER
*/
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define GL1_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define MAX_MSG_LEN_CHUNK 64
typedef struct
{
gl1_t *gl;
GLuint tex;
unsigned tex_width, tex_height;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
video_font_raster_block_t *block;
} gl1_raster_t;
static void gl1_raster_font_free(void *data,
bool is_threaded)
{
@ -302,9 +335,9 @@ static void gl1_raster_font_free(void *data,
if (is_threaded)
if (
font->gl &&
font->gl->ctx_driver &&
font->gl->ctx_driver->make_current)
font->gl
&& font->gl->ctx_driver
&& font->gl->ctx_driver->make_current)
font->gl->ctx_driver->make_current(true);
glDeleteTextures(1, &font->tex);
@ -315,12 +348,10 @@ static void gl1_raster_font_free(void *data,
static void gl1_raster_font_upload_atlas(gl1_raster_t *font)
{
unsigned i, j;
GLint gl_internal = GL_LUMINANCE_ALPHA;
GLenum gl_format = GL_LUMINANCE_ALPHA;
size_t ncomponents = 2;
uint8_t *tmp = NULL;
tmp = (uint8_t*)calloc(font->tex_height, font->tex_width * ncomponents);
GLint gl_internal = GL_LUMINANCE_ALPHA;
GLenum gl_format = GL_LUMINANCE_ALPHA;
size_t ncomponents = 2;
uint8_t *tmp = (uint8_t*)calloc(font->tex_height, font->tex_width * ncomponents);
switch (ncomponents)
{
@ -375,9 +406,9 @@ static void *gl1_raster_font_init(void *data,
if (is_threaded)
if (
font->gl &&
font->gl->ctx_driver &&
font->gl->ctx_driver->make_current)
font->gl
&& font->gl->ctx_driver
&& font->gl->ctx_driver->make_current)
font->gl->ctx_driver->make_current(false);
glGenTextures(1, &font->tex);
@ -796,37 +827,6 @@ font_renderer_t gl1_raster_font = {
* VIDEO DRIVER
*/
static struct video_ortho gl1_default_ortho = {0, 1, 0, 1, -1, 1};
/* Used for the last pass when rendering to the back buffer. */
static const GLfloat gl1_vertexes_flipped[] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const GLfloat gl1_vertexes[] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl1_tex_coords[] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl1_white_color[] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
};
#ifdef HAVE_OVERLAY
static void gl1_render_overlay(gl1_t *gl,
unsigned width,
@ -933,17 +933,15 @@ static void gl1_overlay_tex_geom(void *data,
tex[6] = x + w;
tex[7] = y + h;
}
#endif
#define IS_POT(x) (((x) & (x - 1)) == 0)
#define GET_POT(x) (IS_POT((x)) ? (x) : next_pow2((x)))
static void *gl1_init(const video_info_t *video,
input_driver_t **input, void **input_data)
{
unsigned full_x, full_y;
#ifdef VITA
static bool vgl_inited = false;
#endif
void *ctx_data = NULL;
const gfx_ctx_driver_t *ctx_driver = NULL;
unsigned mode_width = 0;

View File

@ -98,17 +98,149 @@
coords[5] = yamt; \
coords[7] = yamt
/**
* FORWARD DECLARATIONS
*/
static void gl2_set_viewport(gl2_t *gl,
unsigned viewport_width,
unsigned viewport_height,
bool force_full, bool allow_rotate);
#define MAX_FENCES 4
/**
* DISPLAY DRIVER
*/
#if !defined(HAVE_PSGL)
#ifndef HAVE_GL_SYNC
#define HAVE_GL_SYNC
#endif
#endif
#define GL_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define MAX_MSG_LEN_CHUNK 64
#ifdef HAVE_GL_SYNC
#if defined(HAVE_OPENGLES2)
typedef struct __GLsync *GLsync;
#endif
#endif
#if (!defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3))
#ifdef GL_PIXEL_PACK_BUFFER
#define HAVE_GL_ASYNC_READBACK
#endif
#endif
#if defined(HAVE_PSGL)
#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DOES(a, b, c, d, e)
#define gl2_check_fb_status(target) glCheckFramebufferStatusOES(target)
#define gl2_gen_fb(n, ids) glGenFramebuffersOES(n, ids)
#define gl2_delete_fb(n, fb) glDeleteFramebuffersOES(n, fb)
#define gl2_bind_fb(id) glBindFramebufferOES(RARCH_GL_FRAMEBUFFER, id)
#define gl2_gen_rb glGenRenderbuffersOES
#define gl2_bind_rb glBindRenderbufferOES
#define gl2_fb_rb glFramebufferRenderbufferOES
#define gl2_rb_storage glRenderbufferStorageOES
#define gl2_delete_rb glDeleteRenderbuffersOES
#elif (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DEXT(a, b, c, d, e)
#define gl2_check_fb_status(target) glCheckFramebufferStatusEXT(target)
#define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids)
#define gl2_delete_fb(n, fb) glDeleteFramebuffersEXT(n, fb)
#define gl2_bind_fb(id) glBindFramebufferEXT(RARCH_GL_FRAMEBUFFER, id)
#define gl2_gen_rb glGenRenderbuffersEXT
#define gl2_bind_rb glBindRenderbufferEXT
#define gl2_fb_rb glFramebufferRenderbufferEXT
#define gl2_rb_storage glRenderbufferStorageEXT
#define gl2_delete_rb glDeleteRenderbuffersEXT
#else
#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2D(a, b, c, d, e)
#define gl2_check_fb_status(target) glCheckFramebufferStatus(target)
#define gl2_gen_fb(n, ids) glGenFramebuffers(n, ids)
#define gl2_delete_fb(n, fb) glDeleteFramebuffers(n, fb)
#define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id)
#define gl2_gen_rb glGenRenderbuffers
#define gl2_bind_rb glBindRenderbuffer
#define gl2_fb_rb glFramebufferRenderbuffer
#define gl2_rb_storage glRenderbufferStorage
#define gl2_delete_rb glDeleteRenderbuffers
#endif
#ifndef GL_SYNC_GPU_COMMANDS_COMPLETE
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
#endif
#ifndef GL_SYNC_FLUSH_COMMANDS_BIT
#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
#endif
enum gl2_renderchain_flags
{
GL2_CHAIN_FLAG_EGL_IMAGES = (1 << 0),
GL2_CHAIN_FLAG_HAS_FP_FBO = (1 << 1),
GL2_CHAIN_FLAG_HAS_SRGB_FBO_GLES3 = (1 << 2),
GL2_CHAIN_FLAG_HAS_SRGB_FBO = (1 << 3),
GL2_CHAIN_FLAG_HW_RENDER_DEPTH_INIT = (1 << 4)
};
typedef struct video_shader_ctx_scale
{
struct gfx_fbo_scale *scale;
} video_shader_ctx_scale_t;
typedef struct video_shader_ctx_init
{
const char *path;
const shader_backend_t *shader;
void *data;
void *shader_data;
enum rarch_shader_type shader_type;
struct
{
bool core_context_enabled;
} gl;
} video_shader_ctx_init_t;
typedef struct gl2_renderchain_data
{
int fbo_pass;
#ifdef HAVE_GL_SYNC
GLsync fences[MAX_FENCES];
#endif
GLuint vao;
GLuint fbo[GFX_MAX_SHADERS];
GLuint fbo_texture[GFX_MAX_SHADERS];
GLuint hw_render_depth[GFX_MAX_TEXTURES];
unsigned fence_count;
struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS];
uint8_t flags;
} gl2_renderchain_data_t;
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
typedef struct
{
gl2_t *gl;
GLuint tex;
unsigned tex_width, tex_height;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
video_font_raster_block_t *block;
} gl2_raster_t;
#if defined(__arm__) || defined(__aarch64__)
static int scx0, scx1, scy0, scy1;
@ -124,7 +256,87 @@ static const struct
{ "ARM Mali-4xx", 10 },
{ 0, 0 }
};
#endif
static const shader_backend_t *gl2_shader_ctx_drivers[] = {
#ifdef HAVE_GLSL
&gl_glsl_backend,
#endif
#ifdef HAVE_CG
&gl_cg_backend,
#endif
NULL
};
static struct video_ortho default_ortho = {0, 1, 0, 1, -1, 1};
/* Used for the last pass when rendering to the back buffer. */
static const GLfloat vertexes_flipped[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
/* Used when rendering to an FBO.
* Texture coords have to be aligned
* with vertex coordinates. */
static const GLfloat vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl2_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl2_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const GLfloat tex_coords[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat white_color[16] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
};
/**
* FORWARD DECLARATIONS
*/
static void gl2_set_viewport(gl2_t *gl,
unsigned viewport_width,
unsigned viewport_height,
bool force_full, bool allow_rotate);
#ifdef IOS
/* There is no default frame buffer on iOS. */
void glkitview_bind_fbo(void);
#define gl2_renderchain_bind_backbuffer() glkitview_bind_fbo()
#else
#define gl2_renderchain_bind_backbuffer() gl2_bind_fb(0)
#endif
/**
* DISPLAY DRIVER
*/
#if defined(__arm__) || defined(__aarch64__)
static void scissor_set_rectangle(
int x0, int x1, int y0, int y1, int sc)
{
@ -153,20 +365,6 @@ static bool scissor_is_outside_rectangle(
#define MALI_BUG
#endif
static const GLfloat gl2_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat gl2_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const float *gfx_display_gl2_get_default_vertices(void)
{
return &gl2_vertexes[0];
@ -469,36 +667,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_gl = {
/**
* FONT DRIVER
*/
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define GL_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define MAX_MSG_LEN_CHUNK 64
typedef struct
{
gl2_t *gl;
GLuint tex;
unsigned tex_width, tex_height;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
video_font_raster_block_t *block;
} gl2_raster_t;
static void gl2_raster_font_free(void *data,
bool is_threaded)
{
@ -971,174 +1139,6 @@ font_renderer_t gl2_raster_font = {
/*
* VIDEO DRIVER
*/
typedef struct video_shader_ctx_scale
{
struct gfx_fbo_scale *scale;
} video_shader_ctx_scale_t;
typedef struct video_shader_ctx_init
{
const char *path;
const shader_backend_t *shader;
void *data;
void *shader_data;
enum rarch_shader_type shader_type;
struct
{
bool core_context_enabled;
} gl;
} video_shader_ctx_init_t;
static const shader_backend_t *gl2_shader_ctx_drivers[] = {
#ifdef HAVE_GLSL
&gl_glsl_backend,
#endif
#ifdef HAVE_CG
&gl_cg_backend,
#endif
NULL
};
static struct video_ortho default_ortho = {0, 1, 0, 1, -1, 1};
/* Used for the last pass when rendering to the back buffer. */
static const GLfloat vertexes_flipped[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
/* Used when rendering to an FBO.
* Texture coords have to be aligned
* with vertex coordinates. */
static const GLfloat vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat tex_coords[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat white_color[16] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
};
#define MAX_FENCES 4
#if !defined(HAVE_PSGL)
#ifndef HAVE_GL_SYNC
#define HAVE_GL_SYNC
#endif
#endif
#ifdef HAVE_GL_SYNC
#if defined(HAVE_OPENGLES2)
typedef struct __GLsync *GLsync;
#endif
#endif
enum gl2_renderchain_flags
{
GL2_CHAIN_FLAG_EGL_IMAGES = (1 << 0),
GL2_CHAIN_FLAG_HAS_FP_FBO = (1 << 1),
GL2_CHAIN_FLAG_HAS_SRGB_FBO_GLES3 = (1 << 2),
GL2_CHAIN_FLAG_HAS_SRGB_FBO = (1 << 3),
GL2_CHAIN_FLAG_HW_RENDER_DEPTH_INIT = (1 << 4)
};
typedef struct gl2_renderchain_data
{
int fbo_pass;
#ifdef HAVE_GL_SYNC
GLsync fences[MAX_FENCES];
#endif
GLuint vao;
GLuint fbo[GFX_MAX_SHADERS];
GLuint fbo_texture[GFX_MAX_SHADERS];
GLuint hw_render_depth[GFX_MAX_TEXTURES];
unsigned fence_count;
struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS];
uint8_t flags;
} gl2_renderchain_data_t;
#if (!defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3))
#ifdef GL_PIXEL_PACK_BUFFER
#define HAVE_GL_ASYNC_READBACK
#endif
#endif
#if defined(HAVE_PSGL)
#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DOES(a, b, c, d, e)
#define gl2_check_fb_status(target) glCheckFramebufferStatusOES(target)
#define gl2_gen_fb(n, ids) glGenFramebuffersOES(n, ids)
#define gl2_delete_fb(n, fb) glDeleteFramebuffersOES(n, fb)
#define gl2_bind_fb(id) glBindFramebufferOES(RARCH_GL_FRAMEBUFFER, id)
#define gl2_gen_rb glGenRenderbuffersOES
#define gl2_bind_rb glBindRenderbufferOES
#define gl2_fb_rb glFramebufferRenderbufferOES
#define gl2_rb_storage glRenderbufferStorageOES
#define gl2_delete_rb glDeleteRenderbuffersOES
#elif (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DEXT(a, b, c, d, e)
#define gl2_check_fb_status(target) glCheckFramebufferStatusEXT(target)
#define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids)
#define gl2_delete_fb(n, fb) glDeleteFramebuffersEXT(n, fb)
#define gl2_bind_fb(id) glBindFramebufferEXT(RARCH_GL_FRAMEBUFFER, id)
#define gl2_gen_rb glGenRenderbuffersEXT
#define gl2_bind_rb glBindRenderbufferEXT
#define gl2_fb_rb glFramebufferRenderbufferEXT
#define gl2_rb_storage glRenderbufferStorageEXT
#define gl2_delete_rb glDeleteRenderbuffersEXT
#else
#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2D(a, b, c, d, e)
#define gl2_check_fb_status(target) glCheckFramebufferStatus(target)
#define gl2_gen_fb(n, ids) glGenFramebuffers(n, ids)
#define gl2_delete_fb(n, fb) glDeleteFramebuffers(n, fb)
#define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id)
#define gl2_gen_rb glGenRenderbuffers
#define gl2_bind_rb glBindRenderbuffer
#define gl2_fb_rb glFramebufferRenderbuffer
#define gl2_rb_storage glRenderbufferStorage
#define gl2_delete_rb glDeleteRenderbuffers
#endif
#ifndef GL_SYNC_GPU_COMMANDS_COMPLETE
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
#endif
#ifndef GL_SYNC_FLUSH_COMMANDS_BIT
#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
#endif
/* Prototypes */
#ifdef IOS
/* There is no default frame buffer on iOS. */
void glkitview_bind_fbo(void);
#define gl2_renderchain_bind_backbuffer() glkitview_bind_fbo()
#else
#define gl2_renderchain_bind_backbuffer() gl2_bind_fb(0)
#endif
static unsigned gl2_get_alignment(unsigned pitch)
{
if (pitch & 1)

View File

@ -59,6 +59,29 @@
#include "../gfx_widgets.h"
#endif
static const struct video_ortho gl3_default_ortho = {0, 1, 0, 1, -1, 1};
static const float gl3_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const float gl3_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const float gl3_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,
1.0f, 1.0f, 1.0f, 1.0f,
};
/**
* FORWARD DECLARATIONS
*/
@ -87,27 +110,6 @@ static void gl3_bind_scratch_vbo(gl3_t *gl, const void *data, size_t size)
* DISPLAY DRIVER
*/
static const float gl3_vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const float gl3_tex_coords[8] = {
0, 1,
1, 1,
0, 0,
1, 0
};
static const float gl3_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,
1.0f, 1.0f, 1.0f, 1.0f,
};
static void *gfx_display_gl3_get_default_mvp(void *data)
{
gl3_t *gl3 = (gl3_t*)data;
@ -859,8 +861,6 @@ font_renderer_t gl3_raster_font = {
* VIDEO DRIVER
*/
static const struct video_ortho gl3_default_ortho = {0, 1, 0, 1, -1, 1};
static void gl3_deinit_fences(gl3_t *gl)
{
size_t i;

View File

@ -55,6 +55,15 @@
#include "../font_driver.h"
typedef struct
{
GX2Texture texture;
GX2_vec2* ubo_tex;
const font_renderer_driver_t* font_driver;
void* font_data;
struct font_atlas* atlas;
} gx2_font_t;
/* Temporary workaround for GX2 not being able to poll flags during init */
static gfx_ctx_driver_t gx2_fake_context;
@ -70,6 +79,13 @@ static const wiiu_render_mode_t gx2_render_mode_map[] =
{1920, 1080, GX2_TV_RENDER_MODE_WIDE_1080P} /* GX2_TV_SCAN_MODE_1080P */
};
/*
* FORWARD DECLARATIONS
*/
static bool gx2_set_shader(void *data,
enum rarch_shader_type type, const char *path);
/*
* DISPLAY DRIVER
*/
@ -364,15 +380,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_wiiu = {
* FONT DRIVER
*/
typedef struct
{
GX2Texture texture;
GX2_vec2* ubo_tex;
const font_renderer_driver_t* font_driver;
void* font_data;
struct font_atlas* atlas;
} gx2_font_t;
static void* gx2_font_init(void* data, const char* font_path,
float font_size, bool is_threaded)
{
@ -732,9 +739,6 @@ font_renderer_t wiiu_font =
* VIDEO DRIVER
*/
static bool gx2_set_shader(void *data,
enum rarch_shader_type type, const char *path);
static void gx2_set_tex_coords(frame_vertex_t *v,
GX2Texture *texture, float u0, float v0,
float u1, float v1,

View File

@ -120,9 +120,6 @@ enum
GX_RESOLUTIONS_LAST = GX_RESOLUTIONS_640_480,
};
extern syssram* __SYS_LockSram(void);
extern u32 __SYS_UnlockSram(u32 write);
struct gx_overlay_data
{
GXTexObj tex;
@ -201,7 +198,7 @@ static size_t display_list_size = 0;
static GXRModeObj gx_mode;
float verts[16] ATTRIBUTE_ALIGN(32) = {
float verts[16] ATTRIBUTE_ALIGN(32) = {
-1, 1, -0.5,
1, 1, -0.5,
-1, -1, -0.5,
@ -215,7 +212,7 @@ float vertex_ptr[8] ATTRIBUTE_ALIGN(32) = {
1, 1,
};
u8 color_ptr[16] ATTRIBUTE_ALIGN(32) = {
u8 color_ptr[16] ATTRIBUTE_ALIGN(32) = {
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
@ -265,13 +262,17 @@ unsigned menu_gx_resolutions[][2] = {
{ 640, 480 },
};
/*
* FORWARD DECLARATIONS
*/
extern syssram* __SYS_LockSram(void);
extern u32 __SYS_UnlockSram(u32 write);
static void retrace_callback(u32 retrace_count)
{
uint32_t level = 0;
(void)retrace_count;
g_draw_done = true;
g_draw_done = true;
OSSignalCond(g_video_cond);
_CPU_ISR_Disable(level);
retraceCount = retrace_count;
@ -282,9 +283,9 @@ static bool gx_is_valid_xorigin(gx_video_t *gx, int origin)
{
if (!gx)
return false;
if (origin < 0 || origin + gx->used_system_xOrigin < 0 ||
gx_mode.viWidth + origin + gx->used_system_xOrigin > 720)
if ( (origin < 0)
|| (origin + gx->used_system_xOrigin < 0)
|| (gx_mode.viWidth + origin + gx->used_system_xOrigin > 720))
return false;
return true;
}
@ -613,8 +614,6 @@ static void gx_get_video_output_size(void *data,
if (!global)
return;
(void)data;
/* If the current index is out of bound default it to zero */
if (global->console.screen.resolutions.current.id > GX_RESOLUTIONS_LAST)
global->console.screen.resolutions.current.id = 0;

View File

@ -52,13 +52,13 @@ enum
typedef struct network
{
int fd;
unsigned video_width;
unsigned video_height;
unsigned screen_width;
unsigned screen_height;
char address[256];
uint16_t port;
int fd;
char address[256];
} network_video_t;
static unsigned char *network_menu_frame = NULL;

View File

@ -19,7 +19,6 @@
#include <string.h>
#include <stdint.h>
#include "../../verbosity.h"
#include <fcntl.h>
#include <rga/RgaApi.h>
#include <rga/RockchipRgaMacro.h>
@ -27,10 +26,7 @@
#include <xf86drmMode.h>
#include <drm/drm_fourcc.h>
#include "frontend/frontend_driver.h"
#include "../font_driver.h"
#include "libretro.h"
#include <libretro.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
@ -40,8 +36,13 @@
#include "../../menu/menu_driver.h"
#endif
#include "frontend/frontend_driver.h"
#include "../font_driver.h"
#include "../../configuration.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

View File

@ -43,9 +43,27 @@
#define PS2_RESOLUTION_LAST NUM_RM_VMODES - 1
#define RM_VMODE_AUTO 0
/*
* FONT DRIVER
*/
#define A_COLOR_SOURCE 0
#define A_COLOR_DEST 1
#define A_COLOR_NULL 2
#define A_ALPHA_SOURCE 0
#define A_ALPHA_DEST 1
#define A_ALPHA_FIX 2
/* RM Vmode -> GS Vmode conversion table */
struct rm_mode
{
char mode;
short int width;
short int height;
short int VCK;
short int interlace;
short int field;
short int PAR1; /* Pixel Aspect Ratio 1 (For video modes with non-square pixels, like PAL/NTSC) */
short int PAR2; /* Pixel Aspect Ratio 2 (For video modes with non-square pixels, like PAL/NTSC) */
char *desc;
};
typedef struct
{
GSTEXTURE *texture;
@ -53,6 +71,24 @@ typedef struct
void* font_data;
} ps2_font_t;
static struct rm_mode rm_mode_table[NUM_RM_VMODES] = {
/* SDTV modes */
{-1, 704, -1, 4, GS_INTERLACED, GS_FIELD, -1, 11, "AUTO"},
{GS_MODE_PAL, 704, 576, 4, GS_INTERLACED, GS_FIELD, 12, 11, "PAL@50Hz"},
{GS_MODE_NTSC, 704, 480, 4, GS_INTERLACED, GS_FIELD, 10, 11, "NTSC@60Hz"},
/* SDTV special modes */
{GS_MODE_PAL, 704, 288, 4, GS_NONINTERLACED, GS_FRAME, 12, 22, "PAL@50Hz-288p"},
{GS_MODE_NTSC, 704, 240, 4, GS_NONINTERLACED, GS_FRAME, 10, 22, "NTSC@60Hz-240p"},
/* EDTV modes (component cable!) */
{GS_MODE_DTV_480P, 704, 480, 2, GS_NONINTERLACED, GS_FRAME, 10, 11, "DTV480P@60Hz"},
{GS_MODE_DTV_576P, 704, 576, 2, GS_NONINTERLACED, GS_FRAME, 12, 11, "DTV576P@50Hz"},
};
static int vsync_sema_id;
/*
* FONT DRIVER
*/
static void* ps2_font_init(void* data, const char* font_path,
float font_size, bool is_threaded)
{
@ -402,37 +438,8 @@ font_renderer_t ps2_font = {
* VIDEO DRIVER
*/
/* RM Vmode -> GS Vmode conversion table */
struct rm_mode
{
char mode;
short int width;
short int height;
short int VCK;
short int interlace;
short int field;
short int PAR1; /* Pixel Aspect Ratio 1 (For video modes with non-square pixels, like PAL/NTSC) */
short int PAR2; /* Pixel Aspect Ratio 2 (For video modes with non-square pixels, like PAL/NTSC) */
char *desc;
};
static struct rm_mode rm_mode_table[NUM_RM_VMODES] = {
/* SDTV modes */
{-1, 704, -1, 4, GS_INTERLACED, GS_FIELD, -1, 11, "AUTO"},
{GS_MODE_PAL, 704, 576, 4, GS_INTERLACED, GS_FIELD, 12, 11, "PAL@50Hz"},
{GS_MODE_NTSC, 704, 480, 4, GS_INTERLACED, GS_FIELD, 10, 11, "NTSC@60Hz"},
/* SDTV special modes */
{GS_MODE_PAL, 704, 288, 4, GS_NONINTERLACED, GS_FRAME, 12, 22, "PAL@50Hz-288p"},
{GS_MODE_NTSC, 704, 240, 4, GS_NONINTERLACED, GS_FRAME, 10, 22, "NTSC@60Hz-240p"},
/* EDTV modes (component cable!) */
{GS_MODE_DTV_480P, 704, 480, 2, GS_NONINTERLACED, GS_FRAME, 10, 11, "DTV480P@60Hz"},
{GS_MODE_DTV_576P, 704, 576, 2, GS_NONINTERLACED, GS_FRAME, 12, 11, "DTV576P@50Hz"},
};
static int vsync_sema_id;
/* PRIVATE METHODS */
static int vsync_handler()
static int vsync_handler(void)
{
iSignalSema(vsync_sema_id);
@ -442,31 +449,25 @@ static int vsync_handler()
static void rmEnd(ps2_video_t *ps2)
{
if (!ps2->gsGlobal)
return;
gsKit_deinit_global(ps2->gsGlobal);
gsKit_remove_vsync_handler(ps2->vsync_callback_id);
}
static void updateOffSetsIfNeeded(ps2_video_t *ps2)
static void ps2_update_offsets_if_needed(ps2_video_t *ps2)
{
bool shouldUpdate = false;
settings_t *settings = config_get_ptr();
int video_window_offset_x = settings->ints.video_window_offset_x;
int video_window_offset_y = settings->ints.video_window_offset_y;
settings_t *settings = config_get_ptr();
int video_window_offset_x = settings->ints.video_window_offset_x;
int video_window_offset_y = settings->ints.video_window_offset_y;
if (video_window_offset_x != ps2->video_window_offset_x || video_window_offset_y != ps2->video_window_offset_y)
shouldUpdate = true;
if ( (video_window_offset_x != ps2->video_window_offset_x)
|| (video_window_offset_y != ps2->video_window_offset_y))
{
ps2->video_window_offset_x = video_window_offset_x;
ps2->video_window_offset_y = video_window_offset_y;
if (!shouldUpdate)
return;
ps2->video_window_offset_x = video_window_offset_x;
ps2->video_window_offset_y = video_window_offset_y;
gsKit_set_display_offset(ps2->gsGlobal, ps2->video_window_offset_x * rm_mode_table[ps2->vmode].VCK, ps2->video_window_offset_y);
RARCH_LOG("PS2_GFX Change offset: %d, %d\n", ps2->video_window_offset_x, ps2->video_window_offset_y);
gsKit_set_display_offset(ps2->gsGlobal, ps2->video_window_offset_x * rm_mode_table[ps2->vmode].VCK, ps2->video_window_offset_y);
RARCH_LOG("PS2_GFX Change offset: %d, %d\n", ps2->video_window_offset_x, ps2->video_window_offset_y);
}
}
/* Copy of gsKit_sync_flip, but without the 'flip' */
@ -475,8 +476,7 @@ static void gsKit_sync(GSGLOBAL *gsGlobal)
if (!gsGlobal->FirstFrame)
WaitSema(vsync_sema_id);
while (PollSema(vsync_sema_id) >= 0)
;
while (PollSema(vsync_sema_id) >= 0);
}
/* Copy of gsKit_sync_flip, but without the 'sync' */
@ -508,32 +508,33 @@ static void rmSetMode(ps2_video_t *ps2, int force)
/* Cleanup previous gsKit instance */
if (ps2->vmode >= 0)
{
rmEnd(ps2);
if (ps2->gsGlobal)
rmEnd(ps2);
/* Set new mode */
global->console.screen.resolutions.current.id = ps2->vmode;
}
else
/* first driver init */
ps2->vmode = global->console.screen.resolutions.current.id;
ps2->vmode = global->console.screen.resolutions.current.id;
mode = &rm_mode_table[ps2->vmode];
mode = &rm_mode_table[ps2->vmode];
/* Invalidate scaling state */
ps2->iTextureWidth = 0;
ps2->iTextureHeight = 0;
ps2->iTextureWidth = 0;
ps2->iTextureHeight = 0;
ps2->gsGlobal = gsKit_init_global();
ps2->gsGlobal = gsKit_init_global();
gsKit_TexManager_setmode(ps2->gsGlobal, ETM_DIRECT);
ps2->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler);
ps2->gsGlobal->Mode = mode->mode;
ps2->gsGlobal->Width = mode->width;
ps2->gsGlobal->Height = mode->height;
ps2->gsGlobal->Interlace = mode->interlace;
ps2->gsGlobal->Field = mode->field;
ps2->gsGlobal->PSM = GS_PSM_CT16;
ps2->gsGlobal->PSMZ = GS_PSMZ_16S;
ps2->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler);
ps2->gsGlobal->Mode = mode->mode;
ps2->gsGlobal->Width = mode->width;
ps2->gsGlobal->Height = mode->height;
ps2->gsGlobal->Interlace = mode->interlace;
ps2->gsGlobal->Field = mode->field;
ps2->gsGlobal->PSM = GS_PSM_CT16;
ps2->gsGlobal->PSMZ = GS_PSMZ_16S;
ps2->gsGlobal->DoubleBuffering = GS_SETTING_ON;
ps2->gsGlobal->ZBuffering = GS_SETTING_OFF;
ps2->gsGlobal->ZBuffering = GS_SETTING_OFF;
ps2->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
if ((ps2->gsGlobal->Interlace == GS_INTERLACED) && (ps2->gsGlobal->Field == GS_FRAME))
@ -541,7 +542,7 @@ static void rmSetMode(ps2_video_t *ps2, int force)
/* Coordinate space ranges from 0 to 4096 pixels
* Center the buffer in the coordinate space */
ps2->gsGlobal->OffsetX = ((4096 - ps2->gsGlobal->Width) / 2) * 16;
ps2->gsGlobal->OffsetX = ((4096 - ps2->gsGlobal->Width) / 2) * 16;
ps2->gsGlobal->OffsetY = ((4096 - ps2->gsGlobal->Height) / 2) * 16;
gsKit_init_screen(ps2->gsGlobal);
@ -557,22 +558,24 @@ static void rmSetMode(ps2_video_t *ps2, int force)
RARCH_LOG("PS2_GFX New vmode: %d, %d x %d\n", ps2->vmode, ps2->gsGlobal->Width, ps2->gsGlobal->Height);
updateOffSetsIfNeeded(ps2);
ps2_update_offsets_if_needed(ps2);
}
static void rmInit(ps2_video_t *ps2)
{
ee_sema_t sema;
short int mode;
sema.init_count = 0;
sema.max_count = 1;
sema.option = 0;
vsync_sema_id = CreateSema(&sema);
sema.max_count = 1;
sema.option = 0;
short int mode = gsKit_check_rom();
vsync_sema_id = CreateSema(&sema);
mode = gsKit_check_rom();
rm_mode_table[RM_VMODE_AUTO].mode = mode;
rm_mode_table[RM_VMODE_AUTO].mode = mode;
rm_mode_table[RM_VMODE_AUTO].height = (mode == GS_MODE_PAL) ? 576 : 480;
rm_mode_table[RM_VMODE_AUTO].PAR1 = (mode == GS_MODE_PAL) ? 12 : 10;
rm_mode_table[RM_VMODE_AUTO].PAR1 = (mode == GS_MODE_PAL) ? 12 : 10;
dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
@ -583,34 +586,28 @@ static void rmInit(ps2_video_t *ps2)
rmSetMode(ps2, 1);
}
static GSTEXTURE *prepare_new_texture(void)
{
GSTEXTURE *texture = (GSTEXTURE *)calloc(1, sizeof(GSTEXTURE));
return texture;
}
static void init_ps2_video(ps2_video_t *ps2)
{
ps2->vmode = -1;
ps2->vmode = -1;
rmInit(ps2);
ps2->vp.x = 0;
ps2->vp.y = 0;
ps2->vp.width = ps2->gsGlobal->Width;
ps2->vp.height = ps2->gsGlobal->Height;
ps2->vp.full_width = ps2->gsGlobal->Width;
ps2->vp.full_height = ps2->gsGlobal->Height;
ps2->vp.x = 0;
ps2->vp.y = 0;
ps2->vp.width = ps2->gsGlobal->Width;
ps2->vp.height = ps2->gsGlobal->Height;
ps2->vp.full_width = ps2->gsGlobal->Width;
ps2->vp.full_height = ps2->gsGlobal->Height;
ps2->menuTexture = prepare_new_texture();
ps2->coreTexture = prepare_new_texture();
ps2->menuTexture = (GSTEXTURE*)calloc(1, sizeof(GSTEXTURE));
ps2->coreTexture = (GSTEXTURE*)calloc(1, sizeof(GSTEXTURE));
ps2->video_window_offset_x = 0;
ps2->video_window_offset_y = 0;
ps2->video_window_offset_x = 0;
ps2->video_window_offset_y = 0;
/* Used for cores that supports palette */
ps2->iface.interface_type = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2;
ps2->iface.interface_type = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2;
ps2->iface.interface_version = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION;
ps2->iface.coreTexture = ps2->coreTexture;
ps2->iface.coreTexture = ps2->coreTexture;
}
static void ps2_deinit_texture(GSTEXTURE *texture)
@ -620,48 +617,30 @@ static void ps2_deinit_texture(GSTEXTURE *texture)
}
static void set_texture(GSTEXTURE *texture, const void *frame,
int width, int height, int PSM, int filter)
int width, int height, int PSM, int filter)
{
texture->Width = width;
texture->Width = width;
texture->Height = height;
texture->PSM = PSM;
texture->PSM = PSM;
texture->Filter = filter;
texture->Mem = (void *)frame;
texture->Mem = (void *)frame;
}
static int ABS(int v)
static INLINE int ABS(int v)
{
return (v >= 0) ? v : -v;
}
static void setupScalingMode(ps2_video_t *ps2, int iWidth, int iHeight, float fDAR, bool bScaleInteger)
{
GSGLOBAL *gsGlobal = ps2->gsGlobal;
GSGLOBAL *gsGlobal = ps2->gsGlobal;
struct rm_mode *currMode = &rm_mode_table[ps2->vmode];
int iBestFBWidth = currMode->width;
int iBestMagH = currMode->VCK - 1;
float fPAR;
int iBestFBWidth = currMode->width;
int iBestMagH = currMode->VCK - 1;
/* Calculate the pixel aspect ratio (PAR) */
fPAR = (float)currMode->PAR2 / (float)currMode->PAR1;
float fPAR = (float)currMode->PAR2 / (float)currMode->PAR1;
#if defined(DEBUG)
printf("Aspect ratio: %.4f x %.4f = %.4f\n", fDAR, fPAR, fDAR * fPAR);
#endif
if (bScaleInteger == false)
{
/* Assume black bars left/right */
ps2->iDisplayHeight = currMode->height;
ps2->iDisplayWidth = (int)((float)ps2->iDisplayHeight * fDAR * fPAR + 0.5f);
if (ps2->iDisplayWidth > currMode->width)
{
/* Really wide screen, black bars top/bottom */
ps2->iDisplayWidth = currMode->width;
ps2->iDisplayHeight = (int)((float)ps2->iDisplayWidth / (fDAR * fPAR) + 0.5f);
}
}
else
if (bScaleInteger)
{
/* Best match the framebuffer width/height to a multiple of the texture
* Width, rounded down so it always fits */
@ -718,6 +697,18 @@ static void setupScalingMode(ps2_video_t *ps2, int iWidth, int iHeight, float fD
}
}
}
else
{
/* Assume black bars left/right */
ps2->iDisplayHeight = currMode->height;
ps2->iDisplayWidth = (int)((float)ps2->iDisplayHeight * fDAR * fPAR + 0.5f);
if (ps2->iDisplayWidth > currMode->width)
{
/* Really wide screen, black bars top/bottom */
ps2->iDisplayWidth = currMode->width;
ps2->iDisplayHeight = (int)((float)ps2->iDisplayWidth / (fDAR * fPAR) + 0.5f);
}
}
if ((gsGlobal->Interlace == GS_INTERLACED) && (gsGlobal->Field == GS_FRAME))
ps2->iDisplayHeight /= 2;
@ -820,7 +811,7 @@ static bool ps2_frame(void *data, const void *frame,
#endif
/* Check if user change offset values */
updateOffSetsIfNeeded(ps2);
ps2_update_offsets_if_needed(ps2);
if (frame)
{
@ -892,12 +883,6 @@ static bool ps2_frame(void *data, const void *frame,
bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height;
if (!texture_empty)
{
#define A_COLOR_SOURCE 0
#define A_COLOR_DEST 1
#define A_COLOR_NULL 2
#define A_ALPHA_SOURCE 0
#define A_ALPHA_DEST 1
#define A_ALPHA_FIX 2
/* (A - B) * C + D */
gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_SOURCE, 0x20), 0);
gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
@ -980,7 +965,8 @@ static void ps2_free(void *data)
free(ps2->menuTexture);
free(ps2->coreTexture);
rmEnd(ps2);
if (ps2->gsGlobal)
rmEnd(ps2);
if (vsync_sema_id >= 0)
DeleteSema(vsync_sema_id);
@ -989,10 +975,10 @@ static void ps2_free(void *data)
}
static bool ps2_set_shader(void *data,
enum rarch_shader_type type, const char *path) { return false; }
enum rarch_shader_type type, const char *path) { return false; }
static void ps2_set_video_mode(void *data, unsigned fbWidth, unsigned lines,
bool fullscreen)
bool fullscreen)
{
ps2_video_t *ps2 = (ps2_video_t *)data;
if (!ps2)
@ -1009,7 +995,7 @@ static void ps2_set_filtering(void *data, unsigned index, bool smooth, bool ctx_
}
static void ps2_get_video_output_size(void *data,
unsigned *width, unsigned *height, char *desc, size_t desc_len)
unsigned *width, unsigned *height, char *desc, size_t desc_len)
{
ps2_video_t *ps2 = (ps2_video_t *)data;
if (!ps2)
@ -1019,7 +1005,7 @@ static void ps2_get_video_output_size(void *data,
if (ps2->vmode > PS2_RESOLUTION_LAST || ps2->vmode < 0)
ps2->vmode = 0;
*width = rm_mode_table[ps2->vmode].width;
*width = rm_mode_table[ps2->vmode].width;
*height = rm_mode_table[ps2->vmode].height;
strlcpy(desc, rm_mode_table[ps2->vmode].desc, desc_len);
@ -1054,7 +1040,7 @@ static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32,
{
ps2_video_t *ps2 = (ps2_video_t *)data;
int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16);
int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16);
set_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter);
gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->menuTexture);
@ -1078,9 +1064,9 @@ static void ps2_set_osd_msg(void *data, const char *msg,
}
static bool ps2_get_hw_render_interface(void *data,
const struct retro_hw_render_interface **iface)
const struct retro_hw_render_interface **iface)
{
ps2_video_t *ps2 = (ps2_video_t *)data;
ps2_video_t *ps2 = (ps2_video_t *)data;
ps2->iface.padding = empty_ps2_insets;
*iface =
(const struct retro_hw_render_interface *)&ps2->iface;

View File

@ -93,18 +93,6 @@ typedef struct psp1_menu_frame
typedef struct psp1_video
{
bool vsync;
bool rgb32;
bool vblank_not_reached;
bool keep_aspect;
bool should_resize;
bool hw_render;
int tex_filter;
int bpp_log2;
unsigned rotation;
psp1_menu_frame_t menu;
video_viewport_t vp;
void* main_dList;
@ -112,9 +100,18 @@ typedef struct psp1_video
void* draw_buffer;
void* texture;
psp1_sprite_t *frame_coords;
int tex_filter;
int bpp_log2;
unsigned rotation;
bool vsync;
bool rgb32;
bool vblank_not_reached;
bool keep_aspect;
bool should_resize;
bool hw_render;
} psp1_video_t;
/* both row and column count need to be a power of 2 */
/* Both row and column count need to be a power of 2 */
#define PSP_FRAME_ROWS_COUNT 4
#define PSP_FRAME_COLUMNS_COUNT 16
#define PSP_FRAME_SLICE_COUNT (PSP_FRAME_ROWS_COUNT * PSP_FRAME_COLUMNS_COUNT)
@ -129,8 +126,8 @@ static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords,
if (rotation == 0)
{
x0 = x;
y0 = y;
x0 = x;
y0 = y;
step_x = ((float) width) / PSP_FRAME_COLUMNS_COUNT;
step_y = ((float) height) / PSP_FRAME_ROWS_COUNT;
@ -152,8 +149,8 @@ static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords,
}
else if (rotation == 1) /* 90° */
{
x0 = x + width;
y0 = y;
x0 = x + width;
y0 = y;
step_x = -((float) width) / PSP_FRAME_ROWS_COUNT;
step_y = ((float) height) / PSP_FRAME_COLUMNS_COUNT;
@ -175,8 +172,8 @@ static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords,
}
else if (rotation == 2) /* 180° */
{
x0 = x + width;
y0 = y + height;
x0 = x + width;
y0 = y + height;
step_x = -((float) width) / PSP_FRAME_COLUMNS_COUNT;
step_y = -((float) height) / PSP_FRAME_ROWS_COUNT;
@ -198,8 +195,8 @@ static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords,
}
else /* 270° */
{
x0 = x;
y0 = y + height;
x0 = x;
y0 = y + height;
step_x = ((float) width) / PSP_FRAME_ROWS_COUNT;
step_y = -((float) height) / PSP_FRAME_COLUMNS_COUNT;
@ -282,8 +279,8 @@ static void psp_update_viewport(psp1_video_t* psp,
float delta;
float desired_aspect = video_driver_get_aspect_ratio();
if ((fabsf(device_aspect - desired_aspect) < 0.0001f)
|| (fabsf((16.0/9.0) - desired_aspect) < 0.02f))
if ( (fabsf(device_aspect - desired_aspect) < 0.0001f)
|| (fabsf((16.0/9.0) - desired_aspect) < 0.02f))
{
/* If the aspect ratios of screen and desired aspect
* ratio are sufficiently equal (floating point stuff),

View File

@ -73,16 +73,43 @@
if (rsx->shared_context_use) \
rsx->ctx_driver->bind_hw_render(rsx->ctx_data, enable)
/*
* FORWARD DECLARATIONS
*/
#define RSX_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]
static void rsx_set_viewport(void *data, unsigned viewport_width,
unsigned viewport_height, bool force_full, bool allow_rotate);
#define MAX_MSG_LEN_CHUNK 64
/*
* DISPLAY DRIVER
*/
typedef struct
{
rsx_t *rsx;
rsx_vertex_t *vertices;
rsx_texture_t texture;
rsxProgramConst *proj_matrix;
rsxProgramAttrib *pos_index;
rsxProgramAttrib *uv_index;
rsxProgramAttrib *col_index;
rsxProgramAttrib *tex_unit;
rsxVertexProgram* vpo;
rsxFragmentProgram* fpo;
void *vp_ucode;
void *fp_ucode;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
video_font_raster_block_t *block;
u32 tex_width;
u32 tex_height;
u32 fp_offset;
u32 pos_offset;
u32 uv_offset;
u32 col_offset;
} rsx_font_t;
static const float rsx_vertexes[8] = {
0, 0,
@ -98,6 +125,18 @@ static const float rsx_tex_coords[8] = {
1, 0
};
/*
* FORWARD DECLARATIONS
*/
static void rsx_set_viewport(void *data, unsigned viewport_width,
unsigned viewport_height, bool force_full, bool allow_rotate);
/*
* DISPLAY DRIVER
*/
static const float *gfx_display_rsx_get_default_vertices(void)
{
return &rsx_vertexes[0];
@ -294,44 +333,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_rsx = {
* FONT DRIVER
*/
#define RSX_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]
#define MAX_MSG_LEN_CHUNK 64
typedef struct
{
rsx_t *rsx;
rsx_vertex_t *vertices;
rsx_texture_t texture;
rsxProgramConst *proj_matrix;
rsxProgramAttrib *pos_index;
rsxProgramAttrib *uv_index;
rsxProgramAttrib *col_index;
rsxProgramAttrib *tex_unit;
rsxVertexProgram* vpo;
rsxFragmentProgram* fpo;
void *vp_ucode;
void *fp_ucode;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
video_font_raster_block_t *block;
u32 tex_width;
u32 tex_height;
u32 fp_offset;
u32 pos_offset;
u32 uv_offset;
u32 col_offset;
} rsx_font_t;
static void rsx_font_free(void *data,
bool is_threaded)
{

View File

@ -44,24 +44,23 @@
typedef struct sdl_menu_frame
{
bool active;
struct scaler_ctx scaler;
SDL_Surface *frame;
bool active;
} sdl_menu_frame_t;
typedef struct sdl_video
{
bool quitting;
uint8_t font_r;
uint8_t font_g;
uint8_t font_b;
struct scaler_ctx scaler;
sdl_menu_frame_t menu;
SDL_Surface *screen;
void *font;
const font_renderer_driver_t *font_driver;
uint8_t font_r;
uint8_t font_g;
uint8_t font_b;
bool quitting;
} sdl_video_t;
static void sdl_gfx_free(void *data)

View File

@ -69,6 +69,8 @@
typedef struct sdl_rs90_video sdl_rs90_video_t;
struct sdl_rs90_video
{
retro_time_t last_frame_time;
retro_time_t ff_frame_time_min;
SDL_Surface *screen;
void (*scale_frame16)(sdl_rs90_video_t *vid,
uint16_t *src, unsigned width, unsigned height,
@ -76,6 +78,7 @@ struct sdl_rs90_video
void (*scale_frame32)(sdl_rs90_video_t *vid,
uint32_t *src, unsigned width, unsigned height,
unsigned src_pitch);
bitmapfont_lut_t *osd_font;
/* Scaling/padding/cropping parameters */
unsigned content_width;
unsigned content_height;
@ -85,24 +88,21 @@ struct sdl_rs90_video
unsigned frame_padding_y;
unsigned frame_crop_x;
unsigned frame_crop_y;
bool rgb32;
bool menu_active;
bool was_in_menu;
bool mode_valid;
retro_time_t last_frame_time;
retro_time_t ff_frame_time_min;
enum dingux_rs90_softfilter_type softfilter_type;
#if defined(DINGUX_BETA)
enum dingux_refresh_rate refresh_rate;
#endif
uint32_t font_colour32;
uint16_t font_colour16;
uint16_t menu_texture[SDL_RS90_WIDTH * SDL_RS90_HEIGHT];
bool vsync;
bool keep_aspect;
bool scale_integer;
bool quitting;
bitmapfont_lut_t *osd_font;
uint32_t font_colour32;
uint16_t font_colour16;
uint16_t menu_texture[SDL_RS90_WIDTH * SDL_RS90_HEIGHT];
bool rgb32;
bool menu_active;
bool was_in_menu;
bool mode_valid;
};
/* Image interpolation START */

View File

@ -99,27 +99,24 @@ typedef enum tag_DISP_CMD
typedef struct
{
uintptr_t framebuffer_paddr; /* physical address */
int fd_fb;
int fd_disp;
int fb_id; /* /dev/fb0 = 0, /dev/fb1 = 1 */
int xres, yres, bits_per_pixel;
uint8_t *framebuffer_addr; /* mmapped address */
uintptr_t framebuffer_paddr; /* physical address */
uint32_t framebuffer_size; /* total size of the framebuffer */
int framebuffer_height;/* virtual vertical resolution */
uint32_t gfx_layer_size; /* the size of the primary layer */
float refresh_rate;
int xres, yres, bits_per_pixel;
/* Layers support */
int gfx_layer_id;
int layer_id;
int layer_has_scaler;
int layer_buf_x, layer_buf_y, layer_buf_w, layer_buf_h;
int layer_win_x, layer_win_y;
int layer_scaler_is_enabled;
int layer_format;
uint32_t framebuffer_size; /* total size of the framebuffer */
uint32_t gfx_layer_size; /* the size of the primary layer */
float refresh_rate;
uint8_t *framebuffer_addr; /* mmapped address */
} sunxi_disp_t;
typedef struct

View File

@ -45,37 +45,35 @@
typedef struct
{
bool should_resize;
bool keep_aspect;
bool mEglImageBuf;
bool mFontsOn;
void *mFontRenderer;
void *ctx_data;
const gfx_ctx_driver_t *ctx_driver;
const font_renderer_driver_t *font_driver;
char *mLastMsg;
float mScreenAspect;
VGint scissor[4];
VGImageFormat mTexType;
VGImage mImage;
EGLImageKHR last_egl_image;
VGFont mFont;
VGuint mMsgLength;
VGuint mGlyphIndices[1024];
VGPaint mPaintFg;
VGPaint mPaintBg;
unsigned mTextureWidth;
unsigned mTextureHeight;
unsigned mRenderWidth;
unsigned mRenderHeight;
unsigned x1, y1, x2, y2;
uint32_t mFontHeight;
float mScreenAspect;
math_matrix_3x3 mTransformMatrix; /* float alignment */
char *mLastMsg;
VGint scissor[4];
VGImageFormat mTexType;
VGImage mImage;
math_matrix_3x3 mTransformMatrix;
EGLImageKHR last_egl_image;
VGFont mFont;
void *mFontRenderer;
const font_renderer_driver_t *font_driver;
VGuint mMsgLength;
VGuint mGlyphIndices[1024];
VGPaint mPaintFg;
VGPaint mPaintBg;
void *ctx_data;
const gfx_ctx_driver_t *ctx_driver;
bool should_resize;
bool keep_aspect;
bool mEglImageBuf;
bool mFontsOn;
} vg_t;
static PFNVGCREATEEGLIMAGETARGETKHRPROC pvgCreateEGLImageTargetKHR;

View File

@ -43,21 +43,16 @@
#include <defines/psp_defines.h>
#include <psp2/kernel/sysmem.h>
/*
* FORWARD DECLARATIONS
*/
typedef struct
{
vita_video_t *vita;
vita2d_texture *texture;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
} vita_font_t;
extern void *memcpy_neon(void *dst, const void *src, size_t n);
static void vita2d_update_viewport(vita_video_t* vita,
video_frame_info_t *video_info);
static void vita2d_set_viewport_wrapper(void *data, unsigned viewport_width,
unsigned viewport_height, bool force_full, bool allow_rotate);
/*
* DISPLAY DRIVER
*/
static const float vita2d_vertexes[8] = {
static const float vita2d_vertexes[8] = {
0, 0,
1, 0,
0, 1,
@ -71,13 +66,28 @@ static const float vita2d_tex_coords[8] = {
1, 0
};
static const float vita2d_colors[16] = {
static const float vita2d_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,
1.0f, 1.0f, 1.0f, 1.0f,
};
/*
* FORWARD DECLARATIONS
*/
extern void *memcpy_neon(void *dst, const void *src, size_t n);
static void vita2d_update_viewport(vita_video_t* vita,
video_frame_info_t *video_info);
static void vita2d_set_viewport_wrapper(void *data, unsigned viewport_width,
unsigned viewport_height, bool force_full, bool allow_rotate);
/*
* DISPLAY DRIVER
*/
static const float *gfx_display_vita2d_get_default_vertices(void)
{
return &vita2d_vertexes[0];
@ -145,14 +155,7 @@ static void gfx_display_vita2d_draw(gfx_display_ctx_draw_t *draw,
vertices[i].a = *color++;
}
switch (draw->pipeline_id)
{
default:
{
vita2d_draw_array_textured_mat(texture, vertices, draw->coords->vertices, &vita2d->mvp_no_rot);
break;
}
}
vita2d_draw_array_textured_mat(texture, vertices, draw->coords->vertices, &vita2d->mvp_no_rot);
}
static void gfx_display_vita2d_scissor_begin(void *data,
@ -195,15 +198,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_vita2d = {
* FONT DRIVER
*/
typedef struct
{
vita_video_t *vita;
vita2d_texture *texture;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
} vita_font_t;
static void *vita2d_font_init(void *data,
const char *font_path, float font_size,
bool is_threaded)
@ -544,10 +538,11 @@ font_renderer_t vita2d_vita_font = {
static void *vita2d_gfx_init(const video_info_t *video,
input_driver_t **input, void **input_data)
{
vita_video_t *vita = (vita_video_t *)calloc(1, sizeof(vita_video_t));
unsigned temp_width = PSP_FB_WIDTH;
unsigned temp_height = PSP_FB_HEIGHT;
vita2d_video_mode_data video_mode_data = {0};
vita_video_t *vita = (vita_video_t *)
calloc(1, sizeof(vita_video_t));
if (!vita)
return NULL;

View File

@ -56,17 +56,36 @@
#include "../video_coord_array.h"
/*
* VULKAN COMMON
*/
#define VK_REMAP_TO_TEXFMT(fmt) ((fmt == VK_FORMAT_R5G6B5_UNORM_PACK16) ? VK_FORMAT_R8G8B8A8_UNORM : fmt)
typedef struct
{
vk_t *vk;
void *font_data;
struct font_atlas *atlas;
const font_renderer_driver_t *font_driver;
struct vk_vertex *pv;
struct vk_texture texture;
struct vk_texture texture_optimal;
struct vk_buffer_range range;
unsigned vertices;
bool needs_update;
} vulkan_raster_t;
#ifdef VULKAN_DEBUG_TEXTURE_ALLOC
static VkImage vk_images[4 * 1024];
static unsigned vk_count;
static unsigned track_seq;
#endif
/*
* VULKAN COMMON
*/
#ifdef VULKAN_DEBUG_TEXTURE_ALLOC
#if 0
void vulkan_log_textures(void)
{
unsigned i;
@ -77,6 +96,7 @@ void vulkan_log_textures(void)
}
vk_count = 0;
}
#endif
static void vulkan_track_alloc(VkImage image)
{
@ -1274,21 +1294,6 @@ gfx_display_ctx_driver_t gfx_display_ctx_vulkan = {
* FONT DRIVER
*/
typedef struct
{
vk_t *vk;
void *font_data;
struct font_atlas *atlas;
const font_renderer_driver_t *font_driver;
struct vk_vertex *pv;
struct vk_texture texture;
struct vk_texture texture_optimal;
struct vk_buffer_range range;
unsigned vertices;
bool needs_update;
} vulkan_raster_t;
static INLINE void vulkan_font_update_glyph(
vulkan_raster_t *font, const struct font_glyph *glyph)
{

View File

@ -38,6 +38,28 @@
#define UV_LEFT 2
#define UV_RIGHT 3
typedef struct DrawVerticeFormats
{
float x, y, z, w;
unsigned int color;
float u, v;
} DrawVerticeFormats;
typedef struct xenon360_video xenon360_video_t;
typedef struct xenos
{
unsigned char *screen;
struct XenosVertexBuffer *vb;
struct XenosDevice *device;
struct XenosDevice real_device;
struct XenosShader *g_pVertexShader;
struct XenosShader *g_pPixelTexturedShader;
struct XenosSurface *g_pTexture;
bool quitting;
} xenos_t;
/* pixel shader */
const unsigned int g_xps_PS[] =
{
@ -70,27 +92,6 @@ const unsigned int g_xvs_VS[] =
0x00000000, 0x00000000, 0x00000000
};
typedef struct DrawVerticeFormats
{
float x, y, z, w;
unsigned int color;
float u, v;
} DrawVerticeFormats;
typedef struct xenon360_video xenon360_video_t;
typedef struct xenos
{
bool quitting;
unsigned char *screen;
struct XenosVertexBuffer *vb;
struct XenosDevice *device;
struct XenosDevice real_device;
struct XenosShader *g_pVertexShader;
struct XenosShader *g_pPixelTexturedShader;
struct XenosSurface *g_pTexture;
} xenos_t;
static float ScreenUv[4] = {0.f, 1.0f, 1.0f, 0.f};
static void xenon360_free(void *data)
@ -105,17 +106,6 @@ static void xenon360_free(void *data)
static void *xenon360_init(const video_info_t *video,
input_driver_t **input, void **input_data)
{
int i = 0;
xenos_t *xenos = calloc(1, sizeof(xenos_t));
if (!xenos)
return NULL;
xenos->device = &xenos->real_device;
Xe_Init(xenos->device);
Xe_SetRenderTarget(xenos->device, Xe_GetFramebufferSurface(xenos->device));
static const struct XenosVBFFormat vbf =
{
3,
@ -125,6 +115,21 @@ static void *xenon360_init(const video_info_t *video,
{XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
}
};
int i = 0;
/* enable filtering for now */
float x = -1.0f;
float y = 1.0f;
float w = 4.0f;
float h = 4.0f;
xenos_t *xenos = calloc(1, sizeof(xenos_t));
if (!xenos)
return NULL;
xenos->device = &xenos->real_device;
Xe_Init(xenos->device);
Xe_SetRenderTarget(xenos->device, Xe_GetFramebufferSurface(xenos->device));
xenos->g_pPixelTexturedShader = Xe_LoadShaderFromMemory(
xenos->device, (void*)g_xps_PS);
@ -139,51 +144,44 @@ static void *xenon360_init(const video_info_t *video,
edram_init(xenos->device);
/* enable filtering for now */
float x = -1.0f;
float y = 1.0f;
float w = 4.0f;
float h = 4.0f;
xenos->vb = Xe_CreateVertexBuffer(xenos->device, 3 * sizeof(DrawVerticeFormats));
DrawVerticeFormats *Rect = Xe_VB_Lock(xenos->device,
xenos->vb, 0, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE);
ScreenUv[UV_TOP] = ScreenUv[UV_TOP] * 2;
ScreenUv[UV_TOP] = ScreenUv[UV_TOP] * 2;
ScreenUv[UV_LEFT] = ScreenUv[UV_LEFT] * 2;
/* top left */
Rect[0].x = x;
Rect[0].y = y;
Rect[0].u = ScreenUv[UV_BOTTOM];
Rect[0].v = ScreenUv[UV_RIGHT];
Rect[0].color = 0;
/* Top left */
Rect[0].x = x;
Rect[0].y = y;
Rect[0].u = ScreenUv[UV_BOTTOM];
Rect[0].v = ScreenUv[UV_RIGHT];
Rect[0].color = 0;
/* bottom left */
Rect[1].x = x;
Rect[1].y = y - h;
Rect[1].u = ScreenUv[UV_BOTTOM];
Rect[1].v = ScreenUv[UV_LEFT];
Rect[1].color = 0;
/* Bottom left */
Rect[1].x = x;
Rect[1].y = y - h;
Rect[1].u = ScreenUv[UV_BOTTOM];
Rect[1].v = ScreenUv[UV_LEFT];
Rect[1].color = 0;
/* top right */
Rect[2].x = x + w;
Rect[2].y = y;
Rect[2].u = ScreenUv[UV_TOP];
Rect[2].v = ScreenUv[UV_RIGHT];
Rect[2].color = 0;
/* Top right */
Rect[2].x = x + w;
Rect[2].y = y;
Rect[2].u = ScreenUv[UV_TOP];
Rect[2].v = ScreenUv[UV_RIGHT];
Rect[2].color = 0;
Rect[3].x = x + w;
Rect[3].y = y;
Rect[3].u = ScreenUv[UV_TOP];
Rect[3].v = ScreenUv[UV_RIGHT];
Rect[3].color = 0;
Rect[3].x = x + w;
Rect[3].y = y;
Rect[3].u = ScreenUv[UV_TOP];
Rect[3].v = ScreenUv[UV_RIGHT];
Rect[3].color = 0;
for (i = 0; i < 3; i++)
{
Rect[i].z = 0.0;
Rect[i].w = 1.0;
Rect[i].z = 0.0;
Rect[i].w = 1.0;
}
Xe_VB_Unlock(xenos->device, xenos->vb);
@ -199,32 +197,33 @@ static bool xenon360_frame(void *data,
video_frame_info_t *video_info)
{
unsigned y;
xenos_t *xenos = (xenos_t*)data;
uint16_t *dest;
const uint16_t *src;
unsigned stride_in, stride_out, copy_size;
xenos_t *xenos = (xenos_t*)data;
#ifdef HAVE_MENU
bool menu_is_alive = video_info->menu_is_alive;
bool menu_is_alive = video_info->menu_is_alive;
#endif
DrawVerticeFormats
*Rect = NULL;
DrawVerticeFormats *Rect = NULL;
ScreenUv[UV_TOP] = ((float) (width) / (float) XE_W)*2;
ScreenUv[UV_LEFT] = ((float) (height) / (float) XE_H)*2;
ScreenUv[UV_TOP] = ((float) (width) / (float) XE_W)*2;
ScreenUv[UV_LEFT] = ((float) (height) / (float) XE_H)*2;
Rect = Xe_VB_Lock(
xenos->device,
xenos->vb, 0, 3 * sizeof(DrawVerticeFormats), XE_LOCK_WRITE);
Rect = Xe_VB_Lock(xenos->device, xenos->vb,
0, 3 * sizeof(DrawVerticeFormats), XE_LOCK_WRITE);
/* bottom left */
Rect[1].v = ScreenUv[UV_LEFT];
Rect[2].u = ScreenUv[UV_TOP];
/* Bottom left */
Rect[1].v = ScreenUv[UV_LEFT];
Rect[2].u = ScreenUv[UV_TOP];
Xe_VB_Unlock(xenos->device, xenos->vb);
/* Refresh texture cache */
uint16_t *dst = Xe_Surface_LockRect(xenos->device, xenos->g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
const uint16_t *src = frame;
unsigned stride_in = pitch >>1;
unsigned stride_out = xenos->g_pTexture->wpitch >> 1;
unsigned copy_size = width << 1;
dst = Xe_Surface_LockRect(xenos->device, xenos->g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
src = frame;
stride_in = pitch >>1;
stride_out = xenos->g_pTexture->wpitch >> 1;
copy_size = width << 1;
for (y = 0; y < height; y++, dst += stride_out, src += stride_in)
memcpy(dst, src, copy_size);

View File

@ -32,21 +32,20 @@
#include "../../menu/menu_driver.h"
#endif
#include "../../configuration.h"
#include "../font_driver.h"
#include "../common/x11_common.h"
#include "../../configuration.h"
#include "../../verbosity.h"
typedef struct xshm
{
XShmSegmentInfo shmInfo;
XImage* image;
uint8_t *fbptr;
GC gc;
int width;
int height;
bool use_shm;
uint8_t *fbptr;
XShmSegmentInfo shmInfo;
XImage* image;
GC gc;
} xshm_t;
static void *xshm_init(const video_info_t *video,
@ -58,23 +57,23 @@ static void *xshm_init(const video_info_t *video,
XInitThreads();
g_x11_dpy = XOpenDisplay(NULL);
g_x11_dpy = XOpenDisplay(NULL);
xshm->use_shm = true;
if (!XShmQueryExtension(g_x11_dpy))
{
RARCH_LOG("[X11]: XShm extension not found.\n");
xshm->use_shm = false;
xshm->use_shm = false;
}
#ifdef RARCH_INTERNAL
parent = DefaultRootWindow(g_x11_dpy);
parent = DefaultRootWindow(g_x11_dpy);
#else
parent = video->parent;
parent = video->parent;
#endif
attributes.border_pixel=0;
g_x11_win = XCreateWindow(g_x11_dpy, parent,
attributes.border_pixel = 0;
g_x11_win = XCreateWindow(g_x11_dpy, parent,
0, 0, video->width, video->height,
0, 24, CopyFromParent, NULL, CWBorderPixel, &attributes);
XSetWindowBackground(g_x11_dpy, g_x11_win, 0);
@ -83,30 +82,34 @@ static void *xshm_init(const video_info_t *video,
if (xshm->use_shm)
{
xshm->shmInfo.shmid = shmget(IPC_PRIVATE, sizeof(uint32_t) * video->width * video->height,
IPC_CREAT|0600);
if (xshm->shmInfo.shmid<0) abort();/* seems like an out of memory situation... let's just blow up. */
IPC_CREAT | 0600);
if (xshm->shmInfo.shmid < 0)
abort();/* seems like an OOM situation... let's just blow up. */
xshm->shmInfo.shmaddr = (char*)shmat(xshm->shmInfo.shmid, 0, 0);
xshm->shmInfo.shmaddr = (char*)shmat(xshm->shmInfo.shmid, 0, 0);
xshm->shmInfo.readOnly = False;
XShmAttach(g_x11_dpy, &xshm->shmInfo);
XSync(g_x11_dpy, False);/* no idea why this is required, but I get weird errors without it. */
xshm->image = XShmCreateImage(g_x11_dpy, NULL, 24, ZPixmap,
xshm->shmInfo.shmaddr, &xshm->shmInfo, video->width, video->height);
xshm->fbptr = (uint8_t*)xshm->shmInfo.shmaddr;
} else {
}
else
{
size_t pitch = video->width * 4;
void *data = malloc (pitch * video->height);
if (!data) abort();/* seems like an out of memory situation... let's just blow up. */
xshm->image = XCreateImage(g_x11_dpy, NULL, 24, ZPixmap, 0,
void *data = malloc (pitch * video->height);
if (!data)
abort(); /* seems like an OOM situation... let's just blow up. */
xshm->image = XCreateImage(g_x11_dpy, NULL, 24, ZPixmap, 0,
(char *) data, video->width,
video->height, 8, pitch);
xshm->fbptr = (uint8_t*)data;
xshm->fbptr = (uint8_t*)data;
XSync(g_x11_dpy, False);
}
xshm->gc = XCreateGC(g_x11_dpy, g_x11_win, 0, NULL);
xshm->gc = XCreateGC(g_x11_dpy, g_x11_win, 0, NULL);
xshm->width = video->width;
xshm->width = video->width;
xshm->height = video->height;
if (!x11_input_ctx_new(true))

View File

@ -55,15 +55,9 @@ typedef struct xv
XShmSegmentInfo shminfo;
XvPortID port;
int depth;
int visualid;
XvImage *image;
uint32_t fourcc;
unsigned width;
unsigned height;
bool keep_aspect;
struct video_viewport vp;
uint8_t *ytable;
@ -73,20 +67,24 @@ typedef struct xv
void *font;
const font_renderer_driver_t *font_driver;
unsigned luma_index[2];
unsigned chroma_u_index;
unsigned chroma_v_index;
uint8_t font_y;
uint8_t font_u;
uint8_t font_v;
void (*render_func)(struct xv*, const void *frame,
unsigned width, unsigned height, unsigned pitch);
void (*render_glyph)(struct xv*, int base_x, int base_y,
const uint8_t *glyph, int atlas_width,
int glyph_width, int glyph_height);
int depth;
int visualid;
unsigned luma_index[2];
unsigned chroma_u_index;
unsigned chroma_v_index;
unsigned width;
unsigned height;
uint32_t fourcc;
uint8_t font_y;
uint8_t font_u;
uint8_t font_v;
bool keep_aspect;
} xv_t;
static void xv_set_nonblock_state(void *data, bool state, bool c, unsigned d)