@@ -213,22 +213,22 @@ static const char *display_frag_glsl =
213
213
" vec4 pvideo_pos;\n"
214
214
" vec4 pvideo_scale;\n"
215
215
" bool pvideo_color_key_enable;\n"
216
- " vec4 pvideo_color_key;\n"
216
+ " vec3 pvideo_color_key;\n"
217
217
"};\n"
218
218
"layout(location = 0) out vec4 out_Color;\n"
219
219
"void main()\n"
220
220
"{\n"
221
221
" vec2 tex_coord = gl_FragCoord.xy/display_size;\n"
222
222
" float rel = display_size.y/textureSize(tex, 0).y/line_offset;\n"
223
- " tex_coord.y = 1 + rel*(tex_coord.y - 1);"
223
+ " tex_coord.y = 1 + rel*(tex_coord.y - 1);\n "
224
224
" tex_coord.y = 1 - tex_coord.y;\n" // GL compat
225
225
" out_Color.rgba = texture(tex, tex_coord);\n"
226
226
" if (pvideo_enable) {\n"
227
227
" vec2 screen_coord = vec2(gl_FragCoord.x, display_size.y - gl_FragCoord.y) * pvideo_scale.z;\n"
228
228
" vec4 output_region = vec4(pvideo_pos.xy, pvideo_pos.xy + pvideo_pos.zw);\n"
229
229
" bvec4 clip = bvec4(lessThan(screen_coord, output_region.xy),\n"
230
230
" greaterThan(screen_coord, output_region.zw));\n"
231
- " if (!any(clip) && (!pvideo_color_key_enable || out_Color.rgba == pvideo_color_key)) {\n"
231
+ " if (!any(clip) && (!pvideo_color_key_enable || out_Color.rgb == pvideo_color_key)) {\n"
232
232
" vec2 out_xy = screen_coord - pvideo_pos.xy;\n"
233
233
" vec2 in_st = (pvideo_in_pos + out_xy * pvideo_scale.xy) / textureSize(pvideo_tex, 0);\n"
234
234
" out_Color.rgba = texture(pvideo_tex, in_st);\n"
@@ -849,10 +849,8 @@ static PvideoState get_pvideo_state(PGRAPHState *pg)
849
849
state .color_key_enabled =
850
850
GET_MASK (d -> pvideo .regs [NV_PVIDEO_FORMAT ], NV_PVIDEO_FORMAT_DISPLAY );
851
851
852
- // TODO: Verify that masking off the top byte is correct.
853
- // SeaBlade sets a color key of 0x80000000 but the texture passed into the
854
- // shader is cleared to 0 alpha.
855
- state .color_key = d -> pvideo .regs [NV_PVIDEO_COLOR_KEY ] & 0xFFFFFF ;
852
+ // Note: PVIDEO color keying ignores alpha.
853
+ state .color_key = d -> pvideo .regs [NV_PVIDEO_COLOR_KEY ] & 0xFFFFF ;
856
854
857
855
assert (state .offset + state .pitch * state .in_height <= state .limit );
858
856
hwaddr end = state .base + state .offset + state .pitch * state .in_height ;
@@ -883,12 +881,11 @@ static void update_uniforms(PGRAPHState *pg, SurfaceBinding *surface)
883
881
if (pvideo -> enabled ) {
884
882
uniform1i (l , uniform_index (l , "pvideo_color_key_enable" ),
885
883
pvideo -> color_key_enabled );
886
- uniform4f (
884
+ uniform3f (
887
885
l , uniform_index (l , "pvideo_color_key" ),
888
886
GET_MASK (pvideo -> color_key , NV_PVIDEO_COLOR_KEY_RED ) / 255.0 ,
889
887
GET_MASK (pvideo -> color_key , NV_PVIDEO_COLOR_KEY_GREEN ) / 255.0 ,
890
- GET_MASK (pvideo -> color_key , NV_PVIDEO_COLOR_KEY_BLUE ) / 255.0 ,
891
- GET_MASK (pvideo -> color_key , NV_PVIDEO_COLOR_KEY_ALPHA ) / 255.0 );
888
+ GET_MASK (pvideo -> color_key , NV_PVIDEO_COLOR_KEY_BLUE ) / 255.0 );
892
889
uniform2f (l , uniform_index (l , "pvideo_in_pos" ), pvideo -> in_s ,
893
890
pvideo -> in_t );
894
891
uniform4f (l , uniform_index (l , "pvideo_pos" ), pvideo -> out_x ,
0 commit comments