- attempt on 8 bit LUT textures

- the DrawSync should draw all polygons from DrawPrim and end scene
This commit is contained in:
Ilya Shurumov 2020-04-01 18:36:02 +06:00
parent 5b7d5a404a
commit 9d9a384134
2 changed files with 15 additions and 7 deletions

View File

@ -1125,6 +1125,7 @@ const char* gte_shader =
"varying vec4 v_texcoord;\n"
"varying vec4 v_color;\n"
"varying vec4 v_page_clut;\n"
"varying vec2 v_pagetype;\n"
"#ifdef VERTEX\n"
" attribute vec4 a_position;\n"
" attribute vec4 a_texcoord; // uv, color multiplier, dither\n"
@ -1134,6 +1135,8 @@ const char* gte_shader =
" v_texcoord = a_texcoord;\n"
" v_color = a_color;\n"
" v_color.xyz *= a_texcoord.z;\n"
" v_pagetype.x = floor(a_position.z / 128.0) + 1.0;\n"
" v_pagetype.y = (4.0 - floor(a_position.z / 128.0));\n"
" v_page_clut.x = fract(a_position.z / 16.0) * 1024.0;\n"
" v_page_clut.y = floor(a_position.z / 16.0) * 256.0;\n"
" v_page_clut.z = fract(a_position.w / 64.0);\n"
@ -1143,14 +1146,14 @@ const char* gte_shader =
"#else\n"
" uniform sampler2D s_texture;\n"
" void main() {\n"
" vec2 uv = (v_texcoord.xy * vec2(0.25, 1.0) + v_page_clut.xy) * vec2(1.0 / 1024.0, 1.0 / 512.0);\n"
" vec2 uv = (v_texcoord.xy * vec2(v_pagetype.x * 0.25, 1.0) + v_page_clut.xy) * vec2(1.0 / 1024.0, 1.0 / 512.0);\n"
" vec2 comp = texture2D(s_texture, uv).rg;\n"
" int index = int(fract(v_texcoord.x / 4.0 + 0.0001) * 4.0);\n"
"\n"
" float v = comp[index / 2] * (255.0 / 16.0);\n"
" float v = comp[index / 2] * (255.0 / pow(16.0,v_pagetype.x));\n"
" float f = floor(v);\n"
"\n"
" vec2 c = vec2( (v - f) * 16.0, f );\n"
" vec2 c = vec2( (v - f) * pow(16.0,v_pagetype.x), f );\n"
"\n"
" vec2 clut_pos = v_page_clut.zw;\n"
" clut_pos.x += mix(c[0], c[1], fract(float(index) / 2.0) * 2.0) / 1024.0;\n"

View File

@ -242,16 +242,24 @@ int ClearImage2(RECT16* rect, u_char r, u_char g, u_char b)
return 0;
}
void DrawAggregatedSplits();
int DrawSync(int mode)
{
// Update VRAM seems needed to be here
Emulator_UpdateVRAM();
//Emulator_UpdateVRAM();
if (drawsync_callback != NULL)
{
drawsync_callback();
}
DrawAggregatedSplits();
Emulator_EndScene();
if (Emulator_BeginScene())
ResetPolyState();
return 0;
}
@ -595,9 +603,6 @@ void DrawPrim(void* p)
}
AggregatePTAGsToSplits((u_long*)p, true);
DrawAggregatedSplits();
//Emulator_EndScene();
}
// parses primitive and pushes it to VBO