mirror of
https://github.com/holub/mame
synced 2025-04-19 07:00:31 +03:00
-bgfx: Fixed UV rounding errors in fs_blit_palette16; Switched back to direct texture upload rather than CPU copy. (#8505) [Ryan Holtz]
This commit is contained in:
parent
cc99e96e30
commit
793875bf4d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -15,7 +15,14 @@ uniform vec4 u_inv_tex_size1;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 srcpix = texture2D(s_tex, v_texcoord0.xy);
|
vec2 original_uv = v_texcoord0.xy * u_tex_size0.xy;
|
||||||
vec2 palette_uv = (srcpix.bg * vec2(256.0, 256.0)) * u_inv_tex_size1.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 + vec2(u_inv_tex_size0.x, 0.0));
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
gl_FragColor = vec4(texture2D(s_pal, palette_uv).rgb, 1.0) * v_color0;
|
gl_FragColor = vec4(texture2D(s_pal, palette_uv).rgb, 1.0) * v_color0;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::Text
|
|||||||
switch (src_format)
|
switch (src_format)
|
||||||
{
|
{
|
||||||
case PRIMFLAG_TEXFORMAT(TEXFORMAT_YUY16):
|
case PRIMFLAG_TEXFORMAT(TEXFORMAT_YUY16):
|
||||||
|
case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16):
|
||||||
dst_format = bgfx::TextureFormat::BGRA8;
|
dst_format = bgfx::TextureFormat::BGRA8;
|
||||||
convert_stride = 2;
|
convert_stride = 2;
|
||||||
out_pitch = rowpixels * 2;
|
out_pitch = rowpixels * 2;
|
||||||
@ -29,26 +30,6 @@ const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::Text
|
|||||||
|
|
||||||
data = bgfx::copy(base, info.storageSize);
|
data = bgfx::copy(base, info.storageSize);
|
||||||
break;
|
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_ARGB32):
|
||||||
case PRIMFLAG_TEXFORMAT(TEXFORMAT_RGB32):
|
case PRIMFLAG_TEXFORMAT(TEXFORMAT_RGB32):
|
||||||
dst_format = bgfx::TextureFormat::BGRA8;
|
dst_format = bgfx::TextureFormat::BGRA8;
|
||||||
|
Loading…
Reference in New Issue
Block a user