soft is hard and hard is soft. Two is one and one is two. No wonder

"-video accel" has substandard performance if opengl is disabled.
[Couriersud]
This commit is contained in:
couriersud 2016-04-18 20:37:14 +02:00
parent 386d141389
commit aef55ded1f
5 changed files with 50 additions and 51 deletions

View File

@ -60,8 +60,8 @@ static inline bool is_transparent(const float &a)
// CONSTRUCTOR & DESTRUCTOR
//============================================================
renderer_sdl1::renderer_sdl1(osd_window *window, int extra_flags)
: osd_renderer(window, extra_flags)
renderer_sdl2::renderer_sdl2(osd_window *window, int extra_flags)
: osd_renderer(window, FLAG_NEEDS_OPENGL | extra_flags)
, m_sdl_renderer(nullptr)
, m_blittimer(0)
, m_last_hofs(0)
@ -101,7 +101,7 @@ renderer_sdl1::renderer_sdl1(osd_window *window, int extra_flags)
#define ENTRY_BM(a,b,f,bm) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, bm, #a, #b, 0, 0, 0, 0}
#define ENTRY_LR(a,b,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, -1}
const copy_info_t renderer_sdl1::s_blit_info_default[] =
const copy_info_t renderer_sdl2::s_blit_info_default[] =
{
/* no rotation */
ENTRY(ARGB32, ARGB8888, argb32_argb32),
@ -180,8 +180,8 @@ const copy_info_t renderer_sdl1::s_blit_info_default[] =
{ -1 },
};
copy_info_t* renderer_sdl1::s_blit_info[SDL_TEXFORMAT_LAST+1] = { nullptr };
bool renderer_sdl1::s_blit_info_initialized = false;
copy_info_t* renderer_sdl2::s_blit_info[SDL_TEXFORMAT_LAST+1] = { nullptr };
bool renderer_sdl2::s_blit_info_initialized = false;
//============================================================
// INLINES
@ -266,7 +266,7 @@ void texture_info::render_quad(const render_primitive &prim, const int x, const
//SDL_RenderCopyEx(m_renderer->m_sdl_renderer, m_texture_id, nullptr, nullptr, 0, nullptr, SDL_FLIP_NONE);
}
void renderer_sdl1::render_quad(texture_info *texture, const render_primitive &prim, const int x, const int y)
void renderer_sdl2::render_quad(texture_info *texture, const render_primitive &prim, const int x, const int y)
{
SDL_Rect target_rect;
@ -303,7 +303,7 @@ void renderer_sdl1::render_quad(texture_info *texture, const render_primitive &p
}
}
int renderer_sdl1::RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat)
int renderer_sdl2::RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat)
{
int i;
for (i = 0; fmt_support[i].format != 0; i++)
@ -333,7 +333,7 @@ int renderer_sdl1::RendererSupportsFormat(Uint32 format, Uint32 access, const ch
// drawsdl_init
//============================================================
void renderer_sdl1::add_list(copy_info_t **head, const copy_info_t *element, Uint32 bm)
void renderer_sdl2::add_list(copy_info_t **head, const copy_info_t *element, Uint32 bm)
{
copy_info_t *newci = global_alloc(copy_info_t);
*newci = *element;
@ -343,7 +343,7 @@ void renderer_sdl1::add_list(copy_info_t **head, const copy_info_t *element, Uin
*head = newci;
}
void renderer_sdl1::expand_copy_info(const copy_info_t *list)
void renderer_sdl2::expand_copy_info(const copy_info_t *list)
{
for (const copy_info_t *bi = list; bi->src_fmt != -1; bi++)
{
@ -362,7 +362,7 @@ void renderer_sdl1::expand_copy_info(const copy_info_t *list)
}
// FIXME: machine only used to access options.
bool renderer_sdl1::init(running_machine &machine)
bool renderer_sdl2::init(running_machine &machine)
{
osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n");
@ -419,7 +419,7 @@ static void drawsdl_show_info(struct SDL_RendererInfo *render_info)
}
int renderer_sdl1::create()
int renderer_sdl2::create()
{
// create renderer
@ -451,7 +451,7 @@ int renderer_sdl1::create()
m_blittimer = 3;
//SDL_RenderPresent(m_sdl_renderer);
osd_printf_verbose("Leave renderer_sdl1::create\n");
osd_printf_verbose("Leave renderer_sdl2::create\n");
struct SDL_RendererInfo render_info;
@ -466,7 +466,7 @@ int renderer_sdl1::create()
// drawsdl_xy_to_render_target
//============================================================
int renderer_sdl1::xy_to_render_target(int x, int y, int *xt, int *yt)
int renderer_sdl2::xy_to_render_target(int x, int y, int *xt, int *yt)
{
*xt = x - m_last_hofs;
*yt = y - m_last_vofs;
@ -481,7 +481,7 @@ int renderer_sdl1::xy_to_render_target(int x, int y, int *xt, int *yt)
// drawsdl_destroy_all_textures
//============================================================
void renderer_sdl1::destroy_all_textures()
void renderer_sdl2::destroy_all_textures()
{
if(window().m_primlist)
{
@ -497,7 +497,7 @@ void renderer_sdl1::destroy_all_textures()
// sdl_info::draw
//============================================================
int renderer_sdl1::draw(int update)
int renderer_sdl2::draw(int update)
{
texture_info *texture=nullptr;
float vofs, hofs;
@ -612,7 +612,7 @@ copy_info_t *texture_info::compute_size_type()
copy_info_t *result = nullptr;
int maxperf = 0;
for (copy_info_t *bi = renderer_sdl1::s_blit_info[m_format]; bi != nullptr; bi = bi->next)
for (copy_info_t *bi = renderer_sdl2::s_blit_info[m_format]; bi != nullptr; bi = bi->next)
{
if ((m_is_rotated == bi->blitter->m_is_rot)
&& (m_sdl_blendmode == bi->bm_mask))
@ -635,7 +635,7 @@ copy_info_t *texture_info::compute_size_type()
return result;
/* try last resort handlers */
for (copy_info_t *bi = renderer_sdl1::s_blit_info[m_format]; bi != nullptr; bi = bi->next)
for (copy_info_t *bi = renderer_sdl2::s_blit_info[m_format]; bi != nullptr; bi = bi->next)
{
if ((m_is_rotated == bi->blitter->m_is_rot)
&& (m_sdl_blendmode == bi->bm_mask))
@ -676,7 +676,7 @@ bool texture_info::matches(const render_primitive &prim, const quad_setup_data &
// texture_create
//============================================================
texture_info::texture_info(renderer_sdl1 *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags)
texture_info::texture_info(renderer_sdl2 *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags)
{
// fill in the core data
m_renderer = renderer;
@ -864,7 +864,7 @@ void quad_setup_data::compute(const render_primitive &prim, const int prescale)
// texture_find
//============================================================
texture_info *renderer_sdl1::texture_find(const render_primitive &prim, const quad_setup_data &setup)
texture_info *renderer_sdl2::texture_find(const render_primitive &prim, const quad_setup_data &setup)
{
HashT texhash = texture_compute_hash(prim.texture, prim.flags);
texture_info *texture;
@ -901,7 +901,7 @@ texture_info *renderer_sdl1::texture_find(const render_primitive &prim, const qu
// exit
//============================================================
void renderer_sdl1::exit()
void renderer_sdl2::exit()
{
if (s_blit_info_initialized)
{
@ -927,7 +927,7 @@ void renderer_sdl1::exit()
// texture_update
//============================================================
texture_info * renderer_sdl1::texture_update(const render_primitive &prim)
texture_info * renderer_sdl2::texture_update(const render_primitive &prim)
{
quad_setup_data setup;
texture_info *texture;
@ -957,7 +957,7 @@ texture_info * renderer_sdl1::texture_update(const render_primitive &prim)
return texture;
}
render_primitive_list *renderer_sdl1::get_primitives()
render_primitive_list *renderer_sdl2::get_primitives()
{
osd_dim nd = window().get_size();
if (nd != m_blit_dim)

View File

@ -10,8 +10,8 @@
#pragma once
#ifndef __DRAW13__
#define __DRAW13__
#ifndef __DRAW20__
#define __DRAW20__
// OSD headers
#ifndef OSD_WINDOWS
@ -50,7 +50,7 @@ struct quad_setup_data
// Textures
//============================================================
class renderer_sdl1;
class renderer_sdl2;
struct copy_info_t;
/* texture_info holds information about a texture */
@ -58,7 +58,7 @@ class texture_info
{
friend class simple_list<texture_info>;
public:
texture_info(renderer_sdl1 *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
texture_info(renderer_sdl2 *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
~texture_info();
void set_data(const render_texinfo &texsource, const UINT32 flags);
@ -91,7 +91,7 @@ private:
void set_coloralphamode(SDL_Texture *texture_id, const render_color *color);
Uint32 m_sdl_access;
renderer_sdl1 * m_renderer;
renderer_sdl2 * m_renderer;
render_texinfo m_texinfo; // copy of the texture info
HashT m_hash; // hash value for the texture (must be >= pointer size)
UINT32 m_flags; // rendering flags
@ -146,12 +146,12 @@ struct copy_info_t
};
/* sdl_info is the information about SDL for the current screen */
class renderer_sdl1 : public osd_renderer
class renderer_sdl2 : public osd_renderer
{
public:
renderer_sdl1(osd_window *window, int extra_flags);
renderer_sdl2(osd_window *window, int extra_flags);
virtual ~renderer_sdl1()
virtual ~renderer_sdl2()
{
destroy_all_textures();
SDL_DestroyRenderer(m_sdl_renderer);
@ -210,4 +210,4 @@ private:
static const copy_info_t s_blit_info_default[];
};
#endif // __DRAW13__
#endif // __DRAW20__

View File

@ -90,7 +90,7 @@ int drawsdl_scale_mode(const char *s)
// drawsdl_init
//============================================================
bool renderer_sdl2::init(running_machine &machine)
bool renderer_sdl1::init(running_machine &machine)
{
osd_printf_verbose("Using SDL multi-window soft driver (SDL 2.0+)\n");
return false;
@ -100,7 +100,7 @@ bool renderer_sdl2::init(running_machine &machine)
// setup_texture for window
//============================================================
void renderer_sdl2::setup_texture(const osd_dim &size)
void renderer_sdl1::setup_texture(const osd_dim &size)
{
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
SDL_DisplayMode mode;
@ -151,7 +151,7 @@ void renderer_sdl2::setup_texture(const osd_dim &size)
// drawsdl_show_info
//============================================================
void renderer_sdl2::show_info(struct SDL_RendererInfo *render_info)
void renderer_sdl1::show_info(struct SDL_RendererInfo *render_info)
{
#define RF_ENTRY(x) {x, #x }
static struct
@ -182,7 +182,7 @@ void renderer_sdl2::show_info(struct SDL_RendererInfo *render_info)
// renderer_sdl2::create
//============================================================
int renderer_sdl2::create()
int renderer_sdl1::create()
{
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
@ -250,7 +250,7 @@ int renderer_sdl2::create()
// DESTRUCTOR
//============================================================
renderer_sdl2::~renderer_sdl2()
renderer_sdl1::~renderer_sdl1()
{
destroy_all_textures();
@ -271,7 +271,7 @@ renderer_sdl2::~renderer_sdl2()
// drawsdl_xy_to_render_target
//============================================================
int renderer_sdl2::xy_to_render_target(int x, int y, int *xt, int *yt)
int renderer_sdl1::xy_to_render_target(int x, int y, int *xt, int *yt)
{
*xt = x - m_last_hofs;
*yt = y - m_last_vofs;
@ -286,7 +286,7 @@ int renderer_sdl2::xy_to_render_target(int x, int y, int *xt, int *yt)
// drawsdl_destroy_all_textures
//============================================================
void renderer_sdl2::destroy_all_textures()
void renderer_sdl1::destroy_all_textures()
{
SDL_DestroyTexture(m_texture_id);
m_texture_id = nullptr;
@ -297,7 +297,7 @@ void renderer_sdl2::destroy_all_textures()
// renderer_sdl2::draw
//============================================================
int renderer_sdl2::draw(int update)
int renderer_sdl1::draw(int update)
{
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
UINT8 *surfptr;
@ -502,7 +502,7 @@ int renderer_sdl2::draw(int update)
#define YMASK (Y1MASK|Y2MASK)
#define UVMASK (UMASK|VMASK)
void renderer_sdl2::yuv_lookup_set(unsigned int pen, unsigned char red,
void renderer_sdl1::yuv_lookup_set(unsigned int pen, unsigned char red,
unsigned char green, unsigned char blue)
{
UINT32 y,u,v;
@ -514,7 +514,7 @@ void renderer_sdl2::yuv_lookup_set(unsigned int pen, unsigned char red,
m_yuv_lookup[pen]=(y<<Y1SHIFT)|(u<<USHIFT)|(y<<Y2SHIFT)|(v<<VSHIFT);
}
void renderer_sdl2::yuv_init()
void renderer_sdl1::yuv_init()
{
unsigned char r,g,b;
if (m_yuv_lookup == nullptr)
@ -670,7 +670,7 @@ static void yuv_RGB_to_YUY2X2(const UINT16 *bitmap, UINT8 *ptr, const int pitch,
}
}
render_primitive_list *renderer_sdl2::get_primitives()
render_primitive_list *renderer_sdl1::get_primitives()
{
osd_dim nd = window().get_size();
if (nd != m_blit_dim)

View File

@ -12,16 +12,16 @@
#pragma once
#ifndef __DRAWSDL2__
#define __DRAWSDL2__
#ifndef __DRAWSDL1__
#define __DRAWSDL1__
/* renderer_sdl2 is the information about SDL for the current screen */
class renderer_sdl2 : public osd_renderer
class renderer_sdl1 : public osd_renderer
{
public:
renderer_sdl2(osd_window *w, int extra_flags)
: osd_renderer(w, extra_flags)
renderer_sdl1(osd_window *w, int extra_flags)
: osd_renderer(w, FLAG_NEEDS_OPENGL | extra_flags)
, m_sdl_renderer(nullptr)
, m_texture_id(nullptr)
, m_yuv_lookup(nullptr)
@ -34,7 +34,7 @@ public:
, m_last_dim(0, 0)
{
}
virtual ~renderer_sdl2();
virtual ~renderer_sdl1();
static bool init(running_machine &machine);
static void exit() { }
@ -83,4 +83,4 @@ struct sdl_scale_mode
void (*yuv_blit)(const UINT16 *bitmap, UINT8 *ptr, const int pitch, const UINT32 *lookup, const int width, const int height);
};
#endif // __DRAWSDL2__
#endif // __DRAWSDL1__

View File

@ -354,7 +354,7 @@ void sdl_osd_interface::window_exit()
switch(video_config.mode)
{
case VIDEO_MODE_SDL2ACCEL:
renderer_sdl2::exit();
renderer_sdl1::exit();
break;
case VIDEO_MODE_SOFT:
renderer_sdl1::exit();
@ -914,7 +914,6 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt )
*
*/
osd_printf_verbose("Enter sdl_info::create\n");
if (window->renderer().has_flags(osd_renderer::FLAG_NEEDS_OPENGL))
{
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );