-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:
MooglyGuy 2021-08-29 17:49:03 +02:00 committed by GitHub
parent cc99e96e30
commit 793875bf4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 22 deletions

View File

@ -15,7 +15,14 @@ uniform vec4 u_inv_tex_size1;
void main()
{
vec4 srcpix = texture2D(s_tex, v_texcoord0.xy);
vec2 palette_uv = (srcpix.bg * vec2(256.0, 256.0)) * u_inv_tex_size1.xy;
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 + 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;
}

View File

@ -22,6 +22,7 @@ const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::Text
switch (src_format)
{
case PRIMFLAG_TEXFORMAT(TEXFORMAT_YUY16):
case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16):
dst_format = bgfx::TextureFormat::BGRA8;
convert_stride = 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);
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;