summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/emu/render.c286
-rw-r--r--src/emu/render.h43
-rw-r--r--src/emu/rendersw.inc34
-rw-r--r--src/lib/util/coretmpl.h8
-rw-r--r--src/lib/util/palette.h3
-rw-r--r--src/osd/sdl/blit13.h44
-rw-r--r--src/osd/sdl/draw13.c39
-rw-r--r--src/osd/sdl/drawogl.c147
-rw-r--r--src/osd/sdl/window.c1
-rw-r--r--src/osd/windows/d3dhlsl.c2
-rw-r--r--src/osd/windows/drawd3d.c18
11 files changed, 399 insertions, 226 deletions
diff --git a/src/emu/render.c b/src/emu/render.c
index 71fd90d281e..5c705f7daf4 100644
--- a/src/emu/render.c
+++ b/src/emu/render.c
@@ -201,6 +201,54 @@ inline item_layer get_layer_and_blendmode(const layout_view &view, int index, in
return item_layer(layer);
}
+//**************************************************************************
+// render_texinfo
+//**************************************************************************
+
+render_texinfo &render_texinfo::operator=(const render_texinfo &src)
+{
+ free_palette();
+ base = src.base;
+ rowpixels = src.rowpixels;
+ width = src.width;
+ height = src.height;
+ seqid = src.seqid;
+ osddata = src.osddata;
+ m_palette = src.m_palette;
+ if (m_palette != NULL)
+ {
+ m_palette->ref_count++;
+ }
+ return *this;
+}
+
+void render_texinfo::set_palette(const dynamic_array<rgb_t> *source)
+{
+ free_palette();
+ if (source != NULL)
+ {
+ m_palette = global_alloc(render_palette_copy);
+ m_palette->palette.copyfrom(*source);
+ m_palette->ref_count = 1;
+ }
+ else
+ {
+ m_palette = NULL;
+ }
+}
+
+void render_texinfo::free_palette()
+{
+ if (m_palette != NULL)
+ {
+ m_palette->ref_count--;
+ if (m_palette->ref_count == 0)
+ {
+ global_free(m_palette);
+ }
+ }
+ m_palette = NULL;
+}
//**************************************************************************
@@ -214,7 +262,25 @@ inline item_layer get_layer_and_blendmode(const layout_view &view, int index, in
void render_primitive::reset()
{
- memset(&type, 0, FPTR(&texcoords + 1) - FPTR(&type));
+ // public state
+ type = INVALID;
+ bounds.x0 = 0;
+ bounds.y0 = 0;
+ bounds.x1 = 0;
+ bounds.y1 = 0;
+ color.a = 0;
+ color.r = 0;
+ color.g = 0;
+ color.b = 0;
+ flags = 0;
+ width = 0.0f;
+ // texcoords; FIXME
+
+ // do not clear m_next!
+ // memset(&type, 0, FPTR(&texcoords + 1) - FPTR(&type));
+
+ texture.set_palette(NULL);
+ texture = render_texinfo();
}
@@ -447,7 +513,7 @@ void render_texture::hq_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const
// get_scaled - get a scaled bitmap (if we can)
//-------------------------------------------------
-bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist)
+void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist)
{
// source width/height come from the source bounds
int swidth = m_sbounds.width();
@@ -460,7 +526,6 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
texinfo.osddata = m_osddata;
// are we scaler-free? if so, just return the source bitmap
- const rgb_t *palbase = (m_format == TEXFORMAT_PALETTE16 || m_format == TEXFORMAT_PALETTEA16) ? m_bitmap->palette()->entry_list_adjusted() : NULL;
if (m_scaler == NULL || (m_bitmap != NULL && swidth == dwidth && sheight == dheight))
{
// add a reference and set up the source bitmap
@@ -469,63 +534,65 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
texinfo.rowpixels = m_bitmap->rowpixels();
texinfo.width = swidth;
texinfo.height = sheight;
- texinfo.palette = palbase;
+ // will be set later
+ texinfo.set_palette(NULL);
texinfo.seqid = ++m_curseq;
- return true;
}
-
- // make sure we can recover the original argb32 bitmap
- bitmap_argb32 dummy;
- bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy;
-
- // is it a size we already have?
- scaled_texture *scaled = NULL;
- int scalenum;
- for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
+ else
{
- scaled = &m_scaled[scalenum];
-
- // we need a non-NULL bitmap with matching dest size
- if (scaled->bitmap != NULL && dwidth == scaled->bitmap->width() && dheight == scaled->bitmap->height())
- break;
+ // make sure we can recover the original argb32 bitmap
+ bitmap_argb32 dummy;
+ bitmap_argb32 &srcbitmap = (m_bitmap != NULL) ? downcast<bitmap_argb32 &>(*m_bitmap) : dummy;
+
+ // is it a size we already have?
+ scaled_texture *scaled = NULL;
+ int scalenum;
+ for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
+ {
+ scaled = &m_scaled[scalenum];
+
+ // we need a non-NULL bitmap with matching dest size
+ if (scaled->bitmap != NULL && dwidth == scaled->bitmap->width() && dheight == scaled->bitmap->height())
+ break;
+ }
+
+ // did we get one?
+ if (scalenum == ARRAY_LENGTH(m_scaled))
+ {
+ int lowest = -1;
+
+ // didn't find one -- take the entry with the lowest seqnum
+ for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
+ if ((lowest == -1 || m_scaled[scalenum].seqid < m_scaled[lowest].seqid) && !primlist.has_reference(m_scaled[scalenum].bitmap))
+ lowest = scalenum;
+ assert_always(lowest != -1, "Too many live texture instances!");
+
+ // throw out any existing entries
+ scaled = &m_scaled[lowest];
+ if (scaled->bitmap != NULL)
+ {
+ m_manager->invalidate_all(scaled->bitmap);
+ global_free(scaled->bitmap);
+ }
+
+ // allocate a new bitmap
+ scaled->bitmap = global_alloc(bitmap_argb32(dwidth, dheight));
+ scaled->seqid = ++m_curseq;
+
+ // let the scaler do the work
+ (*m_scaler)(*scaled->bitmap, srcbitmap, m_sbounds, m_param);
+ }
+
+ // finally fill out the new info
+ primlist.add_reference(scaled->bitmap);
+ texinfo.base = &scaled->bitmap->pix32(0);
+ texinfo.rowpixels = scaled->bitmap->rowpixels();
+ texinfo.width = dwidth;
+ texinfo.height = dheight;
+ // will be set later
+ texinfo.set_palette(NULL);
+ texinfo.seqid = scaled->seqid;
}
-
- // did we get one?
- if (scalenum == ARRAY_LENGTH(m_scaled))
- {
- int lowest = -1;
-
- // didn't find one -- take the entry with the lowest seqnum
- for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
- if ((lowest == -1 || m_scaled[scalenum].seqid < m_scaled[lowest].seqid) && !primlist.has_reference(m_scaled[scalenum].bitmap))
- lowest = scalenum;
- assert_always(lowest != -1, "Too many live texture instances!");
-
- // throw out any existing entries
- scaled = &m_scaled[lowest];
- if (scaled->bitmap != NULL)
- {
- m_manager->invalidate_all(scaled->bitmap);
- global_free(scaled->bitmap);
- }
-
- // allocate a new bitmap
- scaled->bitmap = global_alloc(bitmap_argb32(dwidth, dheight));
- scaled->seqid = ++m_curseq;
-
- // let the scaler do the work
- (*m_scaler)(*scaled->bitmap, srcbitmap, m_sbounds, m_param);
- }
-
- // finally fill out the new info
- primlist.add_reference(scaled->bitmap);
- texinfo.base = &scaled->bitmap->pix32(0);
- texinfo.rowpixels = scaled->bitmap->rowpixels();
- texinfo.width = dwidth;
- texinfo.height = dheight;
- texinfo.palette = palbase;
- texinfo.seqid = scaled->seqid;
- return true;
}
@@ -534,7 +601,7 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
// palette for a texture
//-------------------------------------------------
-const rgb_t *render_texture::get_adjusted_palette(render_container &container)
+const dynamic_array<rgb_t> *render_texture::get_adjusted_palette(render_container &container)
{
// override the palette with our adjusted palette
switch (m_format)
@@ -546,7 +613,7 @@ const rgb_t *render_texture::get_adjusted_palette(render_container &container)
// if no adjustment necessary, return the raw palette
if (!container.has_brightness_contrast_gamma_changes())
- return m_bitmap->palette()->entry_list_adjusted();
+ return m_bitmap->palette()->entry_list_adjusted_darray();
// otherwise, return our adjusted palette
return container.bcg_lookup_table(m_format, m_bitmap->palette());
@@ -582,7 +649,8 @@ render_container::render_container(render_manager &manager, screen_device *scree
m_manager(manager),
m_screen(screen),
m_overlaybitmap(NULL),
- m_overlaytexture(NULL)
+ m_overlaytexture(NULL),
+ m_bcglookup256(0x400)
{
// make sure it is empty
empty();
@@ -722,7 +790,7 @@ float render_container::apply_brightness_contrast_gamma_fp(float value)
// given texture mode
//-------------------------------------------------
-const rgb_t *render_container::bcg_lookup_table(int texformat, palette_t *palette)
+const dynamic_array<rgb_t> *render_container::bcg_lookup_table(int texformat, palette_t *palette)
{
switch (texformat)
{
@@ -736,12 +804,12 @@ const rgb_t *render_container::bcg_lookup_table(int texformat, palette_t *palett
recompute_lookups();
}
assert (palette == &m_palclient->palette());
- return m_bcglookup;
+ return &m_bcglookup;
case TEXFORMAT_RGB32:
case TEXFORMAT_ARGB32:
case TEXFORMAT_YUY16:
- return m_bcglookup256;
+ return &m_bcglookup256;
default:
return NULL;
@@ -1726,24 +1794,28 @@ void render_target::add_container_primitives(render_primitive_list &list, const
int height = (finalorient & ORIENTATION_SWAP_XY) ? (prim->bounds.x1 - prim->bounds.x0) : (prim->bounds.y1 - prim->bounds.y0);
width = MIN(width, m_maxtexwidth);
height = MIN(height, m_maxtexheight);
- if (curitem->texture()->get_scaled(width, height, prim->texture, list))
- {
- // set the palette
- prim->texture.palette = curitem->texture()->get_adjusted_palette(container);
-
- // determine UV coordinates and apply clipping
- prim->texcoords = oriented_texcoords[finalorient];
- clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
-
- // apply the final orientation from the quad flags and then build up the final flags
- prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) |
- PRIMFLAG_TEXORIENT(finalorient) |
- PRIMFLAG_TEXFORMAT(curitem->texture()->format());
- if (blendmode != -1)
- prim->flags |= PRIMFLAG_BLENDMODE(blendmode);
- else
- prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
- }
+
+ curitem->texture()->get_scaled(width, height, prim->texture, list);
+ // set the palette
+#if 1
+ const dynamic_array<rgb_t> *adjusted_pal = curitem->texture()->get_adjusted_palette(container);
+ prim->texture.set_palette(adjusted_pal);
+#else
+ prim->texture.palette = curitem->texture()->get_adjusted_palette(container);
+#endif
+
+ // determine UV coordinates and apply clipping
+ prim->texcoords = oriented_texcoords[finalorient];
+ clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
+
+ // apply the final orientation from the quad flags and then build up the final flags
+ prim->flags = (curitem->flags() & ~(PRIMFLAG_TEXORIENT_MASK | PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) |
+ PRIMFLAG_TEXORIENT(finalorient) |
+ PRIMFLAG_TEXFORMAT(curitem->texture()->format());
+ if (blendmode != -1)
+ prim->flags |= PRIMFLAG_BLENDMODE(blendmode);
+ else
+ prim->flags |= PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
}
else
{
@@ -1778,21 +1850,20 @@ void render_target::add_container_primitives(render_primitive_list &list, const
width = render_round_nearest(prim->bounds.x1) - render_round_nearest(prim->bounds.x0);
height = render_round_nearest(prim->bounds.y1) - render_round_nearest(prim->bounds.y0);
- bool got_scaled = container.overlay()->get_scaled(
+ container.overlay()->get_scaled(
(container_xform.orientation & ORIENTATION_SWAP_XY) ? height : width,
(container_xform.orientation & ORIENTATION_SWAP_XY) ? width : height, prim->texture, list);
- if (got_scaled)
- {
- // determine UV coordinates
- prim->texcoords = oriented_texcoords[container_xform.orientation];
-
- // set the flags and add it to the list
- prim->flags = PRIMFLAG_TEXORIENT(container_xform.orientation) |
- PRIMFLAG_BLENDMODE(BLENDMODE_RGB_MULTIPLY) |
- PRIMFLAG_TEXFORMAT(container.overlay()->format()) |
- PRIMFLAG_TEXSHADE(1);
- }
- list.append_or_return(*prim, !got_scaled);
+
+ // determine UV coordinates
+ prim->texcoords = oriented_texcoords[container_xform.orientation];
+
+ // set the flags and add it to the list
+ prim->flags = PRIMFLAG_TEXORIENT(container_xform.orientation) |
+ PRIMFLAG_BLENDMODE(BLENDMODE_RGB_MULTIPLY) |
+ PRIMFLAG_TEXFORMAT(container.overlay()->format()) |
+ PRIMFLAG_TEXSHADE(1);
+
+ list.append_or_return(*prim, false);
}
}
@@ -1830,21 +1901,20 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob
height = MIN(height, m_maxtexheight);
// get the scaled texture and append it
- bool clipped = true;
- if (texture->get_scaled(width, height, prim->texture, list))
- {
- // compute the clip rect
- render_bounds cliprect;
- cliprect.x0 = render_round_nearest(xform.xoffs);
- cliprect.y0 = render_round_nearest(xform.yoffs);
- cliprect.x1 = render_round_nearest(xform.xoffs + xform.xscale);
- cliprect.y1 = render_round_nearest(xform.yoffs + xform.yscale);
- sect_render_bounds(&cliprect, &m_bounds);
-
- // determine UV coordinates and apply clipping
- prim->texcoords = oriented_texcoords[xform.orientation];
- clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
- }
+
+ texture->get_scaled(width, height, prim->texture, list);
+
+ // compute the clip rect
+ render_bounds cliprect;
+ cliprect.x0 = render_round_nearest(xform.xoffs);
+ cliprect.y0 = render_round_nearest(xform.yoffs);
+ cliprect.x1 = render_round_nearest(xform.xoffs + xform.xscale);
+ cliprect.y1 = render_round_nearest(xform.yoffs + xform.yscale);
+ sect_render_bounds(&cliprect, &m_bounds);
+
+ // determine UV coordinates and apply clipping
+ prim->texcoords = oriented_texcoords[xform.orientation];
+ bool clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
// add to the list or free if we're clipped out
list.append_or_return(*prim, clipped);
diff --git a/src/emu/render.h b/src/emu/render.h
index 2e5443bcd58..cfc607a8d5c 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -167,7 +167,6 @@ class layout_view;
// texture scaling callback
typedef void (*texture_scaler_func)(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
-
// render_bounds - floating point bounding rectangle
struct render_bounds
{
@@ -210,15 +209,45 @@ struct render_quad_texuv
// render_texinfo - texture information
-struct render_texinfo
+
+
+struct render_palette_copy
+{
+ int ref_count;
+ dynamic_array<rgb_t> palette;
+};
+
+class render_texinfo
{
+private:
+ render_texinfo(const render_texinfo &src) {}
+public:
+ render_texinfo()
+ : base(NULL), rowpixels(0), width(0), height(0),
+ seqid(0), osddata(0), m_palette(NULL)
+ {}
+ ~render_texinfo()
+ {
+ free_palette();
+ }
+
+ render_texinfo &operator=(const render_texinfo &src);
+
void * base; // base of the data
UINT32 rowpixels; // pixels per row
UINT32 width; // width of the image
UINT32 height; // height of the image
- const rgb_t * palette; // palette for PALETTE16 textures, LUTs for RGB15/RGB32
UINT32 seqid; // sequence ID
UINT64 osddata; // aux data to pass to osd
+
+ const rgb_t * palette() const { return ((m_palette == NULL) ? NULL : &m_palette->palette[0]); }
+
+ void set_palette(const dynamic_array<rgb_t> *source);
+
+private:
+ void free_palette();
+
+ render_palette_copy *m_palette; // palette for PALETTE16 textures, LUTs for RGB15/RGB32
};
@@ -433,8 +462,8 @@ public:
private:
// internal helpers
- bool get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist);
- const rgb_t *get_adjusted_palette(render_container &container);
+ void get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist);
+ const dynamic_array<rgb_t> *get_adjusted_palette(render_container &container);
static const int MAX_TEXTURE_SCALES = 8;
@@ -524,7 +553,7 @@ public:
bool has_brightness_contrast_gamma_changes() const { return (m_user.m_brightness != 1.0f || m_user.m_contrast != 1.0f || m_user.m_gamma != 1.0f); }
UINT8 apply_brightness_contrast_gamma(UINT8 value);
float apply_brightness_contrast_gamma_fp(float value);
- const rgb_t *bcg_lookup_table(int texformat, palette_t *palette = NULL);
+ const dynamic_array<rgb_t> *bcg_lookup_table(int texformat, palette_t *palette = NULL);
private:
// an item describes a high level primitive that is added to a container
@@ -576,7 +605,7 @@ private:
render_texture * m_overlaytexture; // overlay texture
auto_pointer<palette_client> m_palclient; // client to the screen palette
dynamic_array<rgb_t> m_bcglookup; // full palette lookup with bcg adjustments
- rgb_t m_bcglookup256[0x400]; // lookup table for brightness/contrast/gamma
+ dynamic_array<rgb_t> m_bcglookup256; // lookup table for brightness/contrast/gamma
};
diff --git a/src/emu/rendersw.inc b/src/emu/rendersw.inc
index ebfc57608ef..6281dce5e97 100644
--- a/src/emu/rendersw.inc
+++ b/src/emu/rendersw.inc
@@ -130,6 +130,7 @@ private:
static inline UINT32 get_texel_palette16(const render_texinfo &texture, INT32 curu, INT32 curv)
{
+ const rgb_t *palbase = texture.palette();
if (_BilinearFilter)
{
INT32 u0 = curu >> 16;
@@ -144,16 +145,16 @@ private:
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base);
texbase += v0 * texture.rowpixels + u0;
- UINT32 pix00 = texture.palette[texbase[0]];
- UINT32 pix01 = texture.palette[texbase[u1]];
- UINT32 pix10 = texture.palette[texbase[v1]];
- UINT32 pix11 = texture.palette[texbase[u1 + v1]];
+ UINT32 pix00 = palbase[texbase[0]];
+ UINT32 pix01 = palbase[texbase[u1]];
+ UINT32 pix10 = palbase[texbase[v1]];
+ UINT32 pix11 = palbase[texbase[u1 + v1]];
return rgb_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
}
else
{
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16);
- return texture.palette[texbase[0]];
+ return palbase[texbase[0]];
}
}
@@ -165,6 +166,7 @@ private:
static inline UINT32 get_texel_palette16a(const render_texinfo &texture, INT32 curu, INT32 curv)
{
+ const rgb_t *palbase = texture.palette();
if (_BilinearFilter)
{
INT32 u0 = curu >> 16;
@@ -179,16 +181,16 @@ private:
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base);
texbase += v0 * texture.rowpixels + u0;
- UINT32 pix00 = texture.palette[texbase[0]];
- UINT32 pix01 = texture.palette[texbase[u1]];
- UINT32 pix10 = texture.palette[texbase[v1]];
- UINT32 pix11 = texture.palette[texbase[u1 + v1]];
+ UINT32 pix00 = palbase[texbase[0]];
+ UINT32 pix01 = palbase[texbase[u1]];
+ UINT32 pix10 = palbase[texbase[v1]];
+ UINT32 pix11 = palbase[texbase[u1 + v1]];
return rgba_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
}
else
{
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16);
- return texture.palette[texbase[0]];
+ return palbase[texbase[0]];
}
}
@@ -912,7 +914,7 @@ private:
static void draw_quad_yuy16_none(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{
- const rgb_t *palbase = prim.texture.palette;
+ const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx;
@@ -1082,7 +1084,7 @@ private:
static void draw_quad_rgb32(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{
- const rgb_t *palbase = prim.texture.palette;
+ const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx;
@@ -1252,7 +1254,7 @@ private:
static void draw_quad_rgb32_add(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{
- const rgb_t *palbase = prim.texture.palette;
+ const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx;
@@ -1390,7 +1392,7 @@ private:
static void draw_quad_argb32_alpha(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{
- const rgb_t *palbase = prim.texture.palette;
+ const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx;
@@ -1536,7 +1538,7 @@ private:
static void draw_quad_argb32_multiply(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{
- const rgb_t *palbase = prim.texture.palette;
+ const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx;
@@ -1655,7 +1657,7 @@ private:
static void draw_quad_argb32_add(const render_primitive &prim, _PixelType *dstdata, UINT32 pitch, quad_setup_data &setup)
{
- const rgb_t *palbase = prim.texture.palette;
+ const rgb_t *palbase = prim.texture.palette();
INT32 dudx = setup.dudx;
INT32 dvdx = setup.dvdx;
INT32 endx = setup.endx;
diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h
index e798f0dd7c9..55faa0fde0c 100644
--- a/src/lib/util/coretmpl.h
+++ b/src/lib/util/coretmpl.h
@@ -99,6 +99,14 @@ public:
void resize_and_clear(int count, UINT8 data = 0) { resize(count); clear(data); }
void resize_keep_and_clear_new(int count, UINT8 data = 0) { int oldcount = m_count; resize_keep(count); if (oldcount < m_count) clear_internal(oldcount, m_count - oldcount, data); }
+ // batch operations
+ void copyfrom(const dynamic_array<_ElementType> &source)
+ {
+ resize(source.count());
+ for (int i=0; i < source.count(); i++)
+ m_array[i] = source[i];
+ }
+
private:
// internal helpers
void expand_internal(int count)
diff --git a/src/lib/util/palette.h b/src/lib/util/palette.h
index 939138e613d..0992655ee3c 100644
--- a/src/lib/util/palette.h
+++ b/src/lib/util/palette.h
@@ -170,7 +170,8 @@ public:
// entry list getters
const rgb_t *entry_list_raw() const { return m_entry_color; }
- const rgb_t *entry_list_adjusted() const { return m_adjusted_color; }
+ const dynamic_array<rgb_t> *entry_list_adjusted_darray() const { return &m_adjusted_color; }
+ const rgb_t *entry_list_adjusted() const { return m_adjusted_color; }
const rgb_t *entry_list_adjusted_rgb15() const { return m_adjusted_rgb15; }
// group adjustments
diff --git a/src/osd/sdl/blit13.h b/src/osd/sdl/blit13.h
index e415a81dbd0..0888f00da8c 100644
--- a/src/osd/sdl/blit13.h
+++ b/src/osd/sdl/blit13.h
@@ -53,47 +53,47 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
#define OP_RGB32_ARGB32(_src) ((_src) | 0xff000000)
#define OP_RGB32PAL_ARGB32(_src) \
- (texsource->palette[0x200 + (((_src) >> 16) & 0xff) ] | \
- texsource->palette[0x100 + (((_src) >> 8) & 0xff) ] | \
- texsource->palette[((_src) & 0xff) ] | 0xff000000)
+ (palbase[0x200 + (((_src) >> 16) & 0xff) ] | \
+ palbase[0x100 + (((_src) >> 8) & 0xff) ] | \
+ palbase[((_src) & 0xff) ] | 0xff000000)
-#define OP_PAL16_ARGB32(_src) (0xff000000 | texsource->palette[_src])
+#define OP_PAL16_ARGB32(_src) (0xff000000 | palbase[_src])
-#define OP_PAL16A_ARGB32(_src) (texsource->palette[_src])
+#define OP_PAL16A_ARGB32(_src) (palbase[_src])
#define OP_RGB15_ARGB32(_src) (0xff000000 | ((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) | \
((((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) >> 5) & 0x070707))
-#define OP_RGB15PAL_ARGB32(_src) (0xff000000 | texsource->palette[0x40 + ((_src >> 10) & 0x1f)] | \
- texsource->palette[0x20 + ((_src >> 5) & 0x1f)] | texsource->palette[0x00 + ((_src >> 0) & 0x1f)])
+#define OP_RGB15PAL_ARGB32(_src) (0xff000000 | palbase[0x40 + ((_src >> 10) & 0x1f)] | \
+ palbase[0x20 + ((_src >> 5) & 0x1f)] | palbase[0x00 + ((_src >> 0) & 0x1f)])
#define OP_ARGB32_RGB32(_pixel) premult32(_pixel)
-#define OP_PAL16A_RGB32(_src) premult32(texsource->palette[_src])
+#define OP_PAL16A_RGB32(_src) premult32(palbase[_src])
-#define OP_PAL16_ARGB1555(_src) ((texsource->palette[_src]&0xf80000) >> 9 | \
- (texsource->palette[_src]&0x00f800) >> 6 | \
- (texsource->palette[_src]&0x0000f8) >> 3 | 0x8000)
+#define OP_PAL16_ARGB1555(_src) ((palbase[_src]&0xf80000) >> 9 | \
+ (palbase[_src]&0x00f800) >> 6 | \
+ (palbase[_src]&0x0000f8) >> 3 | 0x8000)
#define OP_RGB15_ARGB1555(_src) ((_src) | 0x8000)
-#define OP_RGB15PAL_ARGB1555(_src) ((texsource->palette[(_src) >> 10] & 0xf8) << 7 | \
- (texsource->palette[((_src) >> 5) & 0x1f] & 0xf8) << 2 | \
- (texsource->palette[(_src) & 0x1f] & 0xf8) >> 3 | 0x8000)
+#define OP_RGB15PAL_ARGB1555(_src) ((palbase[(_src) >> 10] & 0xf8) << 7 | \
+ (palbase[((_src) >> 5) & 0x1f] & 0xf8) << 2 | \
+ (palbase[(_src) & 0x1f] & 0xf8) >> 3 | 0x8000)
#define OP_YUV16_UYVY(_src) (_src)
-#define OP_YUV16PAL_UYVY(_src) ((texsource->palette[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff))
+#define OP_YUV16PAL_UYVY(_src) ((palbase[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff))
-#define OP_YUV16PAL_YVYU(_src) ((texsource->palette[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8))
+#define OP_YUV16PAL_YVYU(_src) ((palbase[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8))
#define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8))
#define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \
(((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) )
-#define OP_YUV16PAL_YUY2(_src) ( (texsource->palette[((_src)>>8) & 0xff]) | \
- (texsource->palette[((_src)>>24) & 0xff]<<16) | \
+#define OP_YUV16PAL_YUY2(_src) ( (palbase[((_src)>>8) & 0xff]) | \
+ (palbase[((_src)>>24) & 0xff]<<16) | \
(((_src)<<8)&0xff00ff00) )
#define OP_YUV16_ARGB32(_src) \
@@ -101,12 +101,12 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
| ((UINT64)ycc_to_rgb(((_src) >> 24) & 0xff, (_src) & 0xff , ((_src)>>16) & 0xff) << 32)
#define OP_YUV16PAL_ARGB32(_src) \
- (UINT64)ycc_to_rgb(texsource->palette[((_src) >> 8) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) \
- | ((UINT64)ycc_to_rgb(texsource->palette[((_src) >> 24) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) << 32)
+ (UINT64)ycc_to_rgb(palbase[((_src) >> 8) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) \
+ | ((UINT64)ycc_to_rgb(palbase[((_src) >> 24) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) << 32)
#define OP_YUV16_ARGB32ROT(_src) pixel_ycc_to_rgb(&(_src))
-#define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), texsource->palette)
+#define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), palbase)
//============================================================
// Copy and rotation
@@ -114,6 +114,7 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
#define TEXCOPY_M( _name, _src_type, _dest_type, _op, _len_div) \
INLINE void texcopy_##_name (texture_info *texture, const render_texinfo *texsource) { \
+ const rgb_t *palbase = texsource->palette(); \
int x, y; \
/* loop over Y */ \
for (y = 0; y < texsource->height; y++) { \
@@ -133,6 +134,7 @@ INLINE void texcopy_##_name (texture_info *texture, const render_texinfo *texsou
#define TEXROT( _name, _src_type, _dest_type, _op) \
INLINE void texcopy_rot_##_name (texture_info *texture, const render_texinfo *texsource) { \
+ const rgb_t *palbase = texsource->palette(); \
int x, y; \
quad_setup_data *setup = &texture->setup; \
int dudx = setup->dudx; \
diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c
index a94a04012f4..f39c1396bf9 100644
--- a/src/osd/sdl/draw13.c
+++ b/src/osd/sdl/draw13.c
@@ -60,6 +60,10 @@ enum
struct quad_setup_data
{
+ quad_setup_data()
+ : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0),
+ rotwidth(0), rotheight(0)
+ {}
INT32 dudx, dvdx, dudy, dvdy;
INT32 startu, startv;
INT32 rotwidth, rotheight;
@@ -90,6 +94,12 @@ struct copy_info {
/* texture_info holds information about a texture */
struct texture_info
{
+ texture_info()
+ : next(NULL), hash(0), flags(0), rawwidth(0), rawheight(0), format(0),
+ pixels(NULL), pitch(0), pixels_own(0), texture_id(NULL), copyinfo(NULL),
+ sdl_access(0), sdl_blendmode(SDL_BLENDMODE_NONE), is_rotated(0), last_access(0)
+ {
+ }
texture_info * next; // next texture in the list
HashT hash; // hash value for the texture (must be >= pointer size)
@@ -117,6 +127,12 @@ struct texture_info
/* sdl_info is the information about SDL for the current screen */
struct sdl_info
{
+ sdl_info()
+ : blittimer(0), extra_flags(0), sdl_renderer(NULL), texlist(NULL),
+ texture_max_width(0), texture_max_height(0), last_hofs(0), last_vofs(0),
+ resize_pending(0), resize_width(0), resize_height(0),
+ last_blit_time(0), last_blit_pixels(0)
+ {}
INT32 blittimer;
UINT32 extra_flags;
@@ -441,7 +457,7 @@ static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32
static void add_list(copy_info **head, copy_info *element, Uint32 bm)
{
- copy_info *newci = (copy_info *) osd_malloc(sizeof(copy_info));
+ copy_info *newci = global_alloc(copy_info);
*newci = *element;
newci->bm_mask = bm;
@@ -515,7 +531,7 @@ static void drawsdl2_exit(void)
(int) bi->perf);
freeme = bi;
bi = bi->next;
- osd_free(freeme);
+ global_free(freeme);
}
}
@@ -543,12 +559,10 @@ static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window)
static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
{
// allocate memory for our structures
- sdl_info *sdl = (sdl_info *) osd_malloc(sizeof(*sdl));
+ sdl_info *sdl = global_alloc(sdl_info);
osd_printf_verbose("Enter drawsdl2_window_create\n");
- memset(sdl, 0, sizeof(*sdl));
-
window->dxdata = sdl;
sdl->extra_flags = (window->fullscreen() ?
@@ -819,7 +833,7 @@ static void drawsdl2_window_destroy(sdl_window_info *window)
SDL_DestroyWindow(window->sdl_window);
- osd_free(sdl);
+ global_free(sdl);
window->dxdata = NULL;
}
@@ -879,8 +893,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture_info *texture;
// allocate a new texture
- texture = (texture_info *) osd_malloc(sizeof(*texture));
- memset(texture, 0, sizeof(*texture));
+ texture = global_alloc(texture_info);
// fill in the core data
texture->hash = texture_compute_hash(texsource, flags);
@@ -897,7 +910,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_ARGB32;
break;
case TEXFORMAT_RGB32:
- texture->format = texsource->palette ? SDL_TEXFORMAT_RGB32_PALETTED : SDL_TEXFORMAT_RGB32;
+ texture->format = texsource->palette() ? SDL_TEXFORMAT_RGB32_PALETTED : SDL_TEXFORMAT_RGB32;
break;
case TEXFORMAT_PALETTE16:
texture->format = SDL_TEXFORMAT_PALETTE16;
@@ -906,7 +919,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_PALETTE16A;
break;
case TEXFORMAT_YUY16:
- texture->format = texsource->palette ? SDL_TEXFORMAT_YUY16_PALETTED : SDL_TEXFORMAT_YUY16;
+ texture->format = texsource->palette() ? SDL_TEXFORMAT_YUY16_PALETTED : SDL_TEXFORMAT_YUY16;
break;
default:
@@ -940,7 +953,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
if ( (texture->copyinfo->func != NULL) && (texture->sdl_access == SDL_TEXTUREACCESS_STATIC))
{
- texture->pixels = osd_malloc_array(texture->setup.rotwidth * texture->setup.rotheight * texture->copyinfo->dst_bpp);
+ texture->pixels = malloc(texture->setup.rotwidth * texture->setup.rotheight * texture->copyinfo->dst_bpp);
texture->pixels_own=TRUE;
}
/* add us to the texture list */
@@ -1135,7 +1148,7 @@ static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture)
SDL_DestroyTexture(texture->texture_id);
if ( texture->pixels_own )
{
- osd_free(texture->pixels);
+ free(texture->pixels);
texture->pixels=NULL;
texture->pixels_own=FALSE;
}
@@ -1147,7 +1160,7 @@ static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture)
sdl->texlist = NULL;
else
p->next = texture->next;
- osd_free(texture);
+ global_free(texture);
}
static void drawsdl2_destroy_all_textures(sdl_window_info *window)
diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c
index 594d729389f..61b4e04385f 100644
--- a/src/osd/sdl/drawogl.c
+++ b/src/osd/sdl/drawogl.c
@@ -161,6 +161,25 @@ struct texture_info;
/* texture_info holds information about a texture */
struct texture_info
{
+ texture_info()
+ : hash(0), flags(0), rawwidth(0), rawheight(0),
+ rawwidth_create(0), rawheight_create(0),
+ type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0),
+ texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL),
+ data_own(0), texCoordBufferName(0)
+ {
+ for (int i=0; i<2; i++)
+ {
+ mpass_textureunit[i] = 0;
+ mpass_texture_mamebm[i] = 0;
+ mpass_fbo_mamebm[i] = 0;
+ mpass_texture_scrn[i] = 0;
+ mpass_fbo_scrn[i] = 0;
+ }
+ for (int i=0; i<8; i++)
+ texCoord[i] = 0.0f;
+ }
+
HashT hash; // hash value for the texture (must be >= pointer size)
UINT32 flags; // rendering flags
render_texinfo texinfo; // copy of the texture info
@@ -198,6 +217,36 @@ struct texture_info
/* sdl_info is the information about SDL for the current screen */
struct sdl_info
{
+ sdl_info()
+ : blittimer(0), extra_flags(0),
+#if (SDLMAME_SDL2)
+ gl_context_id(0),
+#else
+ sdlsurf(NULL),
+#endif
+ initialized(0),
+ last_blendmode(0),
+ texture_max_width(0),
+ texture_max_height(0),
+ texpoweroftwo(0),
+ usevbo(0), usepbo(0), usefbo(0), useglsl(0), glsl(NULL),
+ glsl_program_num(0),
+ glsl_program_mb2sc(0),
+ usetexturerect(0),
+ init_context(0),
+ last_hofs(0.0f),
+ last_vofs(0.0f),
+ surf_w(0),
+ surf_h(0)
+ {
+ for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++)
+ texhash[i] = NULL;
+ for (int i=0; i < 2*GLSL_SHADER_MAX; i++)
+ glsl_program[i] = 0;
+ for (int i=0; i < 8; i++)
+ texVerticex[i] = 0.0f;
+ }
+
INT32 blittimer;
UINT32 extra_flags;
@@ -487,8 +536,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
int has_and_allow_texturerect = 0;
// allocate memory for our structures
- sdl = (sdl_info *) osd_malloc(sizeof(*sdl));
- memset(sdl, 0, sizeof(*sdl));
+ sdl = global_alloc(sdl_info);
window->dxdata = sdl;
@@ -1612,7 +1660,7 @@ static void drawogl_window_destroy(sdl_window_info *window)
}
#endif
- osd_free(sdl);
+ global_free(sdl);
window->dxdata = NULL;
}
@@ -1654,7 +1702,7 @@ static void texture_compute_type_subroutine(sdl_info *sdl, const render_texinfo
if ( texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_EQUALS_DEST] &&
!texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_HAS_PALETTE] &&
texture->xprescale == 1 && texture->yprescale == 1 &&
- !texture->borderpix && !texsource->palette &&
+ !texture->borderpix && !texsource->palette() &&
texsource->rowpixels <= sdl->texture_max_width )
{
texture->nocopy = TRUE;
@@ -2068,8 +2116,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture_info *texture;
// allocate a new texture
- texture = (texture_info *) malloc(sizeof(*texture));
- memset(texture, 0, sizeof(*texture));
+ texture = global_alloc(texture_info);
// fill in the core data
texture->hash = texture_compute_hash(texsource, flags);
@@ -2107,7 +2154,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_ARGB32;
break;
case TEXFORMAT_RGB32:
- if (texsource->palette != NULL)
+ if (texsource->palette() != NULL)
texture->format = SDL_TEXFORMAT_RGB32_PALETTED;
else
texture->format = SDL_TEXFORMAT_RGB32;
@@ -2119,7 +2166,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_PALETTE16A;
break;
case TEXFORMAT_YUY16:
- if (texsource->palette != NULL)
+ if (texsource->palette() != NULL)
texture->format = SDL_TEXFORMAT_YUY16_PALETTED;
else
texture->format = SDL_TEXFORMAT_YUY16;
@@ -2143,7 +2190,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
{
if ( texture_shader_create(window, texsource, texture, flags) )
{
- free(texture);
+ global_free(texture);
return NULL;
}
}
@@ -2229,7 +2276,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
sdl->texhash[i] = texture;
break;
}
- assert(i < HASH_SIZE + OVERFLOW_SIZE);
+ assert_always(i < HASH_SIZE + OVERFLOW_SIZE, "texture hash exhausted ...");
}
if(sdl->usevbo)
@@ -2561,23 +2608,23 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou
switch (PRIMFLAG_GET_TEXFORMAT(flags))
{
case TEXFORMAT_PALETTE16:
- copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_PALETTEA16:
- copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_RGB32:
- copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_ARGB32:
- copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_YUY16:
- copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
default:
@@ -2650,7 +2697,7 @@ static int compare_texture_primitive(const texture_info *texture, const render_p
texture->texinfo.width == prim->texture.width &&
texture->texinfo.height == prim->texture.height &&
texture->texinfo.rowpixels == prim->texture.rowpixels &&
- texture->texinfo.palette == prim->texture.palette &&
+ /* texture->texinfo.palette() == prim->texture.palette() && */
((texture->flags ^ prim->flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0)
return 1;
else
@@ -3041,40 +3088,40 @@ static void drawogl_destroy_all_textures(sdl_window_info *window)
sdl->texhash[i] = NULL;
if (texture != NULL)
{
- if(sdl->usevbo)
- {
- pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) );
- texture->texCoordBufferName=0;
- }
-
- if(sdl->usepbo && texture->pbo)
- {
- pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) );
- texture->pbo=0;
- }
-
- if( sdl->glsl_program_num > 1 )
- {
- assert(sdl->usefbo);
- pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]);
- glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]);
- }
-
- if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 )
- {
- assert(sdl->usefbo);
- pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]);
- glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]);
- }
-
- glDeleteTextures(1, (GLuint *)&texture->texture);
- if ( texture->data_own )
- {
- free(texture->data);
- texture->data=NULL;
- texture->data_own=FALSE;
- }
- free(texture);
+ if(sdl->usevbo)
+ {
+ pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) );
+ texture->texCoordBufferName=0;
+ }
+
+ if(sdl->usepbo && texture->pbo)
+ {
+ pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) );
+ texture->pbo=0;
+ }
+
+ if( sdl->glsl_program_num > 1 )
+ {
+ assert(sdl->usefbo);
+ pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]);
+ glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]);
+ }
+
+ if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 )
+ {
+ assert(sdl->usefbo);
+ pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]);
+ glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]);
+ }
+
+ glDeleteTextures(1, (GLuint *)&texture->texture);
+ if ( texture->data_own )
+ {
+ free(texture->data);
+ texture->data=NULL;
+ texture->data_own=FALSE;
+ }
+ global_free(texture);
}
i++;
}
diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c
index a08840fd852..09b313fbbec 100644
--- a/src/osd/sdl/window.c
+++ b/src/osd/sdl/window.c
@@ -656,6 +656,7 @@ static OSDWORK_CALLBACK( sdlwindow_update_cursor_state_wt )
sdlwindow_update_cursor_state(wp->machine(), wp->window());
+ osd_free(wp);
return NULL;
}
diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c
index 200f482b862..69f8b94dcd9 100644
--- a/src/osd/windows/d3dhlsl.c
+++ b/src/osd/windows/d3dhlsl.c
@@ -940,7 +940,7 @@ int shaders::create_resources(bool reset)
texture.rowpixels = shadow_bitmap.rowpixels();
texture.width = shadow_bitmap.width();
texture.height = shadow_bitmap.height();
- texture.palette = NULL;
+ texture.set_palette(NULL);
texture.seqid = 0;
// now create it
diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c
index 250d7b953db..b09904d30af 100644
--- a/src/osd/windows/drawd3d.c
+++ b/src/osd/windows/drawd3d.c
@@ -528,7 +528,7 @@ void texture_manager::create_resources()
texture.rowpixels = m_default_bitmap.rowpixels();
texture.width = m_default_bitmap.width();
texture.height = m_default_bitmap.height();
- texture.palette = NULL;
+ texture.set_palette(NULL);
texture.seqid = 0;
// now create it
@@ -545,7 +545,7 @@ void texture_manager::create_resources()
texture.rowpixels = m_vector_bitmap.rowpixels();
texture.width = m_vector_bitmap.width();
texture.height = m_vector_bitmap.height();
- texture.palette = NULL;
+ texture.set_palette(NULL);
texture.seqid = 0;
// now create it
@@ -2580,28 +2580,28 @@ void texture_info::set_data(const render_texinfo *texsource, UINT32 flags)
switch (PRIMFLAG_GET_TEXFORMAT(flags))
{
case TEXFORMAT_PALETTE16:
- copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix);
+ copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break;
case TEXFORMAT_PALETTEA16:
- copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix);
+ copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break;
case TEXFORMAT_RGB32:
- copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix);
+ copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break;
case TEXFORMAT_ARGB32:
- copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix);
+ copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break;
case TEXFORMAT_YUY16:
if (m_texture_manager->get_yuv_format() == D3DFMT_YUY2)
- copyline_yuy16_to_yuy2((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix);
+ copyline_yuy16_to_yuy2((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
else if (m_texture_manager->get_yuv_format() == D3DFMT_UYVY)
- copyline_yuy16_to_uyvy((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix);
+ copyline_yuy16_to_uyvy((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
else
- copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, m_xborderpix);
+ copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette(), m_xborderpix);
break;
default: