summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules
diff options
context:
space:
mode:
author MooglyGuy <MooglyGuy@users.noreply.github.com>2021-08-24 16:33:47 +0200
committer GitHub <noreply@github.com>2021-08-24 10:33:47 -0400
commita472f4663f0f4269751429f27fcbb48c53807705 (patch)
tree02ba63f0db3dae00b0c0018046d022f360f078e6 /src/osd/modules
parent01106becc6eb55b668d736fa744a85bb62692403 (diff)
-bgfx: Revised fs_blit_palette16 to not use pixel rounding. Fixes issues in carpolo, kncljoe, and others. [Ryan Holtz] (#8488)
Diffstat (limited to 'src/osd/modules')
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc19
-rw-r--r--src/osd/modules/render/bgfxutil.cpp33
2 files changed, 32 insertions, 20 deletions
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc
index c152bfa8fe3..e87f8a76315 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc
@@ -15,22 +15,7 @@ uniform vec4 u_inv_tex_size1;
void main()
{
- // Logic taken from fs_blit_yuy16.sc - we need to do this, because
- // the D3D9 BGFX backend claims to support RG8, but does so in
- // a faulty way by using A8L8, which is not an appropriate format
- // for representing an RG8 texture.
-
- vec2 half_texel = u_inv_tex_size0.xy * vec2(0.5, 0.5);
-
- vec2 original_uv = v_texcoord0.xy * u_tex_size0.xy;
- float mod_val = mod(original_uv.x, 2.0);
- vec2 rounded_uv = vec2(original_uv.x - mod_val, original_uv.y);
- vec4 srcpix = texture2D(s_tex, rounded_uv * u_inv_tex_size0.xy + half_texel.x);
-
- vec2 palette_uv = (srcpix.ra * vec2(256.0, 256.0)) * u_inv_tex_size1.xy;
- if (mod_val < 1.0)
- palette_uv = (srcpix.bg * vec2(256.0, 256.0)) * u_inv_tex_size1.xy;
-
+ vec4 srcpix = texture2D(s_tex, v_texcoord0.xy);
+ vec2 palette_uv = (srcpix.bg * vec2(256.0, 256.0)) * u_inv_tex_size1.xy;
gl_FragColor = vec4(texture2D(s_pal, palette_uv).rgb, 1.0) * v_color0;
- //gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0;
}
diff --git a/src/osd/modules/render/bgfxutil.cpp b/src/osd/modules/render/bgfxutil.cpp
index f0d01e4fa86..88d2fbf399a 100644
--- a/src/osd/modules/render/bgfxutil.cpp
+++ b/src/osd/modules/render/bgfxutil.cpp
@@ -17,23 +17,50 @@
const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::TextureFormat::Enum &dst_format, uint32_t src_format, int rowpixels, int height, const rgb_t *palette, void *base, uint16_t &out_pitch, int &convert_stride)
{
bgfx::TextureInfo info;
+ const bgfx::Memory *data = nullptr;
+
switch (src_format)
{
- case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16):
case PRIMFLAG_TEXFORMAT(TEXFORMAT_YUY16):
dst_format = bgfx::TextureFormat::BGRA8;
convert_stride = 2;
out_pitch = rowpixels * 2;
+ bgfx::calcTextureSize(info, rowpixels / convert_stride, height, 1, false, false, 1, dst_format);
+
+ data = bgfx::copy(base, info.storageSize);
+ break;
+ case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16):
+ {
+ dst_format = bgfx::TextureFormat::BGRA8;
+ convert_stride = 1;
+ out_pitch = rowpixels * 4;
+ bgfx::calcTextureSize(info, rowpixels / convert_stride, height, 1, false, false, 1, dst_format);
+
+ uint16_t *src = (uint16_t *)base;
+ uint16_t *dst_data = new uint16_t[rowpixels * 2 * height];
+ uint16_t *dst = dst_data;
+ for (int i = 0; i < rowpixels * height; i++, src++)
+ {
+ *dst++ = *src;
+ *dst++ = 0;
+ }
+
+ data = bgfx::copy(dst_data, info.storageSize);
+ delete [] dst_data;
break;
+ }
case PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32):
case PRIMFLAG_TEXFORMAT(TEXFORMAT_RGB32):
dst_format = bgfx::TextureFormat::BGRA8;
convert_stride = 1;
out_pitch = rowpixels * 4;
+ bgfx::calcTextureSize(info, rowpixels / convert_stride, height, 1, false, false, 1, dst_format);
+
+ data = bgfx::copy(base, info.storageSize);
break;
}
- bgfx::calcTextureSize(info, rowpixels / convert_stride, height, 1, false, false, 1, dst_format);
- return bgfx::copy(base, info.storageSize);
+
+ return data;
}
const bgfx::Memory* bgfx_util::mame_texture_data_to_bgra32(uint32_t src_format, int width, int height, int rowpixels, const rgb_t *palette, void *base)