trunk/src/osd/modules/render/d3d/d3dhlsl.cpp
| r253014 | r253015 | |
| 940 | 940 | return 1; |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | | yiq_encode_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 944 | | yiq_encode_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 945 | | yiq_encode_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 943 | effect *effects[14] = { |
| 944 | default_effect, |
| 945 | post_effect, |
| 946 | distortion_effect, |
| 947 | prescale_effect, |
| 948 | phosphor_effect, |
| 949 | focus_effect, |
| 950 | deconverge_effect, |
| 951 | color_effect, |
| 952 | yiq_encode_effect, |
| 953 | yiq_decode_effect, |
| 954 | color_effect, |
| 955 | bloom_effect, |
| 956 | downsample_effect, |
| 957 | vector_effect |
| 958 | }; |
| 959 | |
| 960 | for (int i = 0; i < 14; i++) |
| 961 | { |
| 962 | effects[i]->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 963 | effects[i]->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 964 | effects[i]->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 965 | effects[i]->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 966 | effects[i]->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); |
| 967 | effects[i]->add_uniform("SwapXY", uniform::UT_BOOL, uniform::CU_SWAP_XY); |
| 968 | } |
| 969 | |
| 946 | 970 | yiq_encode_effect->add_uniform("CCValue", uniform::UT_FLOAT, uniform::CU_NTSC_CCFREQ); |
| 947 | 971 | yiq_encode_effect->add_uniform("AValue", uniform::UT_FLOAT, uniform::CU_NTSC_A); |
| 948 | 972 | yiq_encode_effect->add_uniform("BValue", uniform::UT_FLOAT, uniform::CU_NTSC_B); |
| r253014 | r253015 | |
| 952 | 976 | yiq_encode_effect->add_uniform("IFreqResponse", uniform::UT_FLOAT, uniform::CU_NTSC_IFREQ); |
| 953 | 977 | yiq_encode_effect->add_uniform("QFreqResponse", uniform::UT_FLOAT, uniform::CU_NTSC_QFREQ); |
| 954 | 978 | yiq_encode_effect->add_uniform("ScanTime", uniform::UT_FLOAT, uniform::CU_NTSC_HTIME); |
| 955 | | |
| 956 | | yiq_decode_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 957 | | yiq_decode_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 958 | | yiq_decode_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 979 | |
| 959 | 980 | yiq_decode_effect->add_uniform("CCValue", uniform::UT_FLOAT, uniform::CU_NTSC_CCFREQ); |
| 960 | 981 | yiq_decode_effect->add_uniform("AValue", uniform::UT_FLOAT, uniform::CU_NTSC_A); |
| 961 | 982 | yiq_decode_effect->add_uniform("BValue", uniform::UT_FLOAT, uniform::CU_NTSC_B); |
| r253014 | r253015 | |
| 967 | 988 | yiq_decode_effect->add_uniform("QFreqResponse", uniform::UT_FLOAT, uniform::CU_NTSC_QFREQ); |
| 968 | 989 | yiq_decode_effect->add_uniform("ScanTime", uniform::UT_FLOAT, uniform::CU_NTSC_HTIME); |
| 969 | 990 | |
| 970 | | color_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 971 | | color_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 972 | | |
| 973 | 991 | color_effect->add_uniform("RedRatios", uniform::UT_VEC3, uniform::CU_COLOR_RED_RATIOS); |
| 974 | 992 | color_effect->add_uniform("GrnRatios", uniform::UT_VEC3, uniform::CU_COLOR_GRN_RATIOS); |
| 975 | 993 | color_effect->add_uniform("BluRatios", uniform::UT_VEC3, uniform::CU_COLOR_BLU_RATIOS); |
| r253014 | r253015 | |
| 977 | 995 | color_effect->add_uniform("Scale", uniform::UT_VEC3, uniform::CU_COLOR_SCALE); |
| 978 | 996 | color_effect->add_uniform("Saturation", uniform::UT_FLOAT, uniform::CU_COLOR_SATURATION); |
| 979 | 997 | |
| 980 | | prescale_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 981 | | |
| 982 | | deconverge_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 983 | | deconverge_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 984 | | deconverge_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 985 | 998 | deconverge_effect->add_uniform("ConvergeX", uniform::UT_VEC3, uniform::CU_CONVERGE_LINEAR_X); |
| 986 | 999 | deconverge_effect->add_uniform("ConvergeY", uniform::UT_VEC3, uniform::CU_CONVERGE_LINEAR_Y); |
| 987 | 1000 | deconverge_effect->add_uniform("RadialConvergeX", uniform::UT_VEC3, uniform::CU_CONVERGE_RADIAL_X); |
| 988 | 1001 | deconverge_effect->add_uniform("RadialConvergeY", uniform::UT_VEC3, uniform::CU_CONVERGE_RADIAL_Y); |
| 989 | 1002 | |
| 990 | | focus_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 991 | | focus_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 992 | | focus_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 993 | | focus_effect->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); |
| 994 | 1003 | focus_effect->add_uniform("Defocus", uniform::UT_VEC2, uniform::CU_FOCUS_SIZE); |
| 995 | | focus_effect->add_uniform("OrientationSwapXY", uniform::UT_BOOL, uniform::CU_ORIENTATION_SWAP); |
| 996 | | focus_effect->add_uniform("RotationSwapXY", uniform::UT_BOOL, uniform::CU_ROTATION_SWAP); |
| 997 | | |
| 998 | | phosphor_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 999 | | phosphor_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 1004 | |
| 1000 | 1005 | phosphor_effect->add_uniform("Phosphor", uniform::UT_VEC3, uniform::CU_PHOSPHOR_LIFE); |
| 1001 | 1006 | |
| 1002 | | downsample_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 1003 | | |
| 1004 | | bloom_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 1005 | | bloom_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 1006 | | |
| 1007 | | post_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 1008 | | post_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 1009 | | post_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 1010 | | post_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 1011 | | post_effect->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); // backward compatibility |
| 1012 | | |
| 1013 | 1007 | post_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING); // backward compatibility |
| 1014 | 1008 | post_effect->add_uniform("CurvatureAmount", uniform::UT_FLOAT, uniform::CU_POST_CURVATURE); // backward compatibility |
| 1015 | 1009 | post_effect->add_uniform("RoundCornerAmount", uniform::UT_FLOAT, uniform::CU_POST_ROUND_CORNER); // backward compatibility |
| r253014 | r253015 | |
| 1030 | 1024 | post_effect->add_uniform("Power", uniform::UT_VEC3, uniform::CU_POST_POWER); |
| 1031 | 1025 | post_effect->add_uniform("Floor", uniform::UT_VEC3, uniform::CU_POST_FLOOR); |
| 1032 | 1026 | |
| 1033 | | post_effect->add_uniform("OrientationSwapXY", uniform::UT_BOOL, uniform::CU_ORIENTATION_SWAP); |
| 1034 | | post_effect->add_uniform("RotationSwapXY", uniform::UT_BOOL, uniform::CU_ROTATION_SWAP); |
| 1035 | 1027 | post_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE); |
| 1036 | 1028 | |
| 1037 | | distortion_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 1038 | | distortion_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 1039 | | distortion_effect->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); |
| 1040 | | |
| 1041 | 1029 | distortion_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING); |
| 1042 | 1030 | distortion_effect->add_uniform("CurvatureAmount", uniform::UT_FLOAT, uniform::CU_POST_CURVATURE); |
| 1043 | 1031 | distortion_effect->add_uniform("RoundCornerAmount", uniform::UT_FLOAT, uniform::CU_POST_ROUND_CORNER); |
| 1044 | 1032 | distortion_effect->add_uniform("SmoothBorderAmount", uniform::UT_FLOAT, uniform::CU_POST_SMOOTH_BORDER); |
| 1045 | 1033 | distortion_effect->add_uniform("ReflectionAmount", uniform::UT_FLOAT, uniform::CU_POST_REFLECTION); |
| 1046 | 1034 | |
| 1047 | | distortion_effect->add_uniform("OrientationSwapXY", uniform::UT_BOOL, uniform::CU_ORIENTATION_SWAP); |
| 1048 | | distortion_effect->add_uniform("RotationSwapXY", uniform::UT_BOOL, uniform::CU_ROTATION_SWAP); |
| 1049 | 1035 | distortion_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE); |
| 1050 | 1036 | |
| 1051 | | vector_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 1052 | | |
| 1053 | | default_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 1054 | | default_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 1055 | | |
| 1056 | 1037 | initialized = true; |
| 1057 | 1038 | |
| 1058 | 1039 | return 0; |
| r253014 | r253015 | |
| 1359 | 1340 | { |
| 1360 | 1341 | int next_index = source_index; |
| 1361 | 1342 | |
| 1343 | // skip deconverge if no influencing settings |
| 1344 | if (options->converge_x[0] == 0.0f && options->converge_x[1] == 0.0f && options->converge_x[2] == 0.0f && |
| 1345 | options->converge_y[0] == 0.0f && options->converge_y[1] == 0.0f && options->converge_y[2] == 0.0f && |
| 1346 | options->radial_converge_x[0] == 0.0f && options->radial_converge_x[1] == 0.0f && options->radial_converge_x[2] == 0.0f && |
| 1347 | options->radial_converge_y[0] == 0.0f && options->radial_converge_y[1] == 0.0f && options->radial_converge_y[2] == 0.0f) |
| 1348 | { |
| 1349 | return next_index; |
| 1350 | } |
| 1351 | |
| 1362 | 1352 | curr_effect = deconverge_effect; |
| 1363 | 1353 | curr_effect->update_uniforms(); |
| 1364 | 1354 | curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); |
| r253014 | r253015 | |
| 1373 | 1363 | { |
| 1374 | 1364 | int next_index = source_index; |
| 1375 | 1365 | |
| 1376 | | float defocus_x = options->defocus[0]; |
| 1377 | | float defocus_y = options->defocus[1]; |
| 1378 | | |
| 1379 | 1366 | // skip defocus if no influencing settings |
| 1380 | | if (defocus_x == 0.0f && defocus_y == 0.0f) |
| 1367 | if (options->defocus[0] == 0.0f && options->defocus[1] == 0.0f) |
| 1381 | 1368 | { |
| 1382 | 1369 | return next_index; |
| 1383 | 1370 | } |
| r253014 | r253015 | |
| 1396 | 1383 | { |
| 1397 | 1384 | int next_index = source_index; |
| 1398 | 1385 | |
| 1386 | // skip phosphor if no influencing settings |
| 1387 | if (options->phosphor[0] == 0.0f && options->defocus[1] == 0.0f && options->defocus[2] == 0.0f) |
| 1388 | { |
| 1389 | return next_index; |
| 1390 | } |
| 1391 | |
| 1399 | 1392 | curr_effect = phosphor_effect; |
| 1400 | 1393 | curr_effect->update_uniforms(); |
| 1401 | 1394 | curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]); |
| r253014 | r253015 | |
| 1421 | 1414 | { |
| 1422 | 1415 | int next_index = source_index; |
| 1423 | 1416 | |
| 1424 | | texture_info *texture = poly->get_texture(); |
| 1425 | | |
| 1426 | 1417 | bool prepare_vector = |
| 1427 | 1418 | machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR; |
| 1428 | 1419 | |
| r253014 | r253015 | |
| 1459 | 1450 | curr_effect->set_vector("BackColor", 3, back_color); |
| 1460 | 1451 | curr_effect->set_vector("ScreenScale", 2, screen_scale); |
| 1461 | 1452 | curr_effect->set_vector("ScreenOffset", 2, screen_offset); |
| 1462 | | curr_effect->set_float("ScanlineOffset", texture->get_cur_frame() == 0 ? 0.0f : options->scanline_offset); |
| 1453 | curr_effect->set_float("ScanlineOffset", curr_texture->get_cur_frame() == 0 ? 0.0f : options->scanline_offset); |
| 1463 | 1454 | curr_effect->set_bool("PrepareBloom", prepare_bloom); |
| 1464 | 1455 | curr_effect->set_bool("PrepareVector", prepare_vector); |
| 1465 | 1456 | |
| r253014 | r253015 | |
| 1473 | 1464 | { |
| 1474 | 1465 | int next_index = source_index; |
| 1475 | 1466 | |
| 1476 | | bool prepare_vector = |
| 1477 | | machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR; |
| 1478 | | float bloom_rescale = options->bloom_scale; |
| 1479 | | |
| 1480 | 1467 | // skip downsample if no influencing settings |
| 1481 | | if (bloom_rescale == 0.0f) |
| 1468 | if (options->bloom_scale == 0.0f) |
| 1482 | 1469 | { |
| 1483 | 1470 | return next_index; |
| 1484 | 1471 | } |
| 1485 | 1472 | |
| 1473 | bool prepare_vector = |
| 1474 | machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR; |
| 1475 | |
| 1486 | 1476 | curr_effect = downsample_effect; |
| 1487 | 1477 | curr_effect->update_uniforms(); |
| 1488 | 1478 | curr_effect->set_bool("PrepareVector", prepare_vector); |
| r253014 | r253015 | |
| 1519 | 1509 | { |
| 1520 | 1510 | int next_index = source_index; |
| 1521 | 1511 | |
| 1522 | | float bloom_rescale = options->bloom_scale; |
| 1523 | | |
| 1524 | 1512 | // skip bloom if no influencing settings |
| 1525 | | if (bloom_rescale == 0.0f) |
| 1513 | if (options->bloom_scale == 0.0f) |
| 1526 | 1514 | { |
| 1527 | 1515 | return next_index; |
| 1528 | 1516 | } |
| r253014 | r253015 | |
| 1558 | 1546 | curr_effect->set_vector("LevelASize", 2, bloom_dims[10]); |
| 1559 | 1547 | |
| 1560 | 1548 | curr_effect->set_int("BloomBlendMode", options->bloom_blend_mode); |
| 1561 | | curr_effect->set_float("BloomScale", bloom_rescale); |
| 1549 | curr_effect->set_float("BloomScale", options->bloom_scale); |
| 1562 | 1550 | curr_effect->set_vector("BloomOverdrive", 3, options->bloom_overdrive); |
| 1563 | 1551 | |
| 1564 | 1552 | curr_effect->set_texture("DiffuseA", rt->prescale_texture[next_index]); |
| r253014 | r253015 | |
| 1755 | 1743 | // render on screen |
| 1756 | 1744 | d3d->set_wrap(D3DTADDRESS_MIRROR); |
| 1757 | 1745 | next_index = screen_pass(rt, next_index, poly, vertnum); |
| 1758 | | d3d->set_wrap(PRIMFLAG_GET_TEXWRAP(poly->get_texture()->get_flags()) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); |
| 1746 | d3d->set_wrap(PRIMFLAG_GET_TEXWRAP(curr_texture->get_flags()) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); |
| 1759 | 1747 | |
| 1760 | 1748 | curr_texture->increment_frame_count(); |
| 1761 | 1749 | curr_texture->mask_frame_count(options->yiq_phase_count); |
| r253014 | r253015 | |
| 2961 | 2949 | } |
| 2962 | 2950 | case CU_SOURCE_DIMS: |
| 2963 | 2951 | { |
| 2964 | | vec2f sourcedims = shadersys->curr_texture->get_rawdims(); |
| 2965 | | m_shader->set_vector("SourceDims", 2, &sourcedims.c.x); |
| 2952 | if (shadersys->curr_texture != NULL) |
| 2953 | { |
| 2954 | vec2f sourcedims = shadersys->curr_texture->get_rawdims(); |
| 2955 | m_shader->set_vector("SourceDims", 2, &sourcedims.c.x); |
| 2956 | } |
| 2957 | |
| 2966 | 2958 | break; |
| 2967 | 2959 | } |
| 2968 | 2960 | case CU_SOURCE_RECT: |
| 2969 | | { |
| 2970 | | vec2f delta = shadersys->curr_texture->get_uvstop() - shadersys->curr_texture->get_uvstart(); |
| 2971 | | m_shader->set_vector("SourceRect", 2, &delta.c.x); |
| 2961 | { |
| 2962 | bool prepare_vector = |
| 2963 | d3d->window().machine().first_screen()->screen_type() == SCREEN_TYPE_VECTOR; |
| 2964 | |
| 2965 | if (prepare_vector) |
| 2966 | { |
| 2967 | float delta[2] = { 1.0f, 1.0f }; |
| 2968 | m_shader->set_vector("SourceRect", 2, delta); |
| 2969 | break; |
| 2970 | } |
| 2971 | |
| 2972 | if (shadersys->curr_texture != NULL) |
| 2973 | { |
| 2974 | vec2f delta = shadersys->curr_texture->get_uvstop() - shadersys->curr_texture->get_uvstart(); |
| 2975 | m_shader->set_vector("SourceRect", 2, &delta.c.x); |
| 2976 | break; |
| 2977 | } |
| 2978 | |
| 2972 | 2979 | break; |
| 2973 | 2980 | } |
| 2974 | 2981 | case CU_TARGET_DIMS: |
| 2975 | 2982 | { |
| 2976 | | if (shadersys->curr_render_target == NULL) |
| 2983 | if (shadersys->curr_render_target != NULL) |
| 2977 | 2984 | { |
| 2978 | | float targetdims[2] = { 0.0f, 0.0f }; |
| 2985 | float targetdims[2] = { |
| 2986 | static_cast<float>(shadersys->curr_render_target->target_width), |
| 2987 | static_cast<float>(shadersys->curr_render_target->target_height) }; |
| 2979 | 2988 | m_shader->set_vector("TargetDims", 2, targetdims); |
| 2980 | 2989 | } |
| 2981 | | else |
| 2982 | | { |
| 2983 | | float targetdims[2] = { static_cast<float>(shadersys->curr_render_target->target_width), static_cast<float>(shadersys->curr_render_target->target_height) }; |
| 2984 | | m_shader->set_vector("TargetDims", 2, targetdims); |
| 2985 | | } |
| 2986 | 2990 | break; |
| 2987 | 2991 | } |
| 2988 | 2992 | case CU_QUAD_DIMS: |
| 2989 | 2993 | { |
| 2990 | | float quaddims[2] = { shadersys->curr_poly->get_prim_width(), shadersys->curr_poly->get_prim_height() }; |
| 2991 | | m_shader->set_vector("QuadDims", 2, quaddims); |
| 2994 | if (shadersys->curr_poly != NULL) |
| 2995 | { |
| 2996 | float quaddims[2] = { |
| 2997 | shadersys->curr_poly->get_prim_width(), |
| 2998 | shadersys->curr_poly->get_prim_height() }; |
| 2999 | m_shader->set_vector("QuadDims", 2, quaddims); |
| 3000 | } |
| 2992 | 3001 | break; |
| 2993 | 3002 | } |
| 2994 | 3003 | |
| 3004 | case CU_SWAP_XY: |
| 3005 | { |
| 3006 | bool orientation_swap_xy = |
| 3007 | (d3d->window().machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY; |
| 3008 | bool rotation_swap_xy = |
| 3009 | (d3d->window().target()->orientation() & ROT90) == ROT90 || |
| 3010 | (d3d->window().target()->orientation() & ROT270) == ROT270; |
| 3011 | m_shader->set_bool("SwapXY", orientation_swap_xy ^ rotation_swap_xy); |
| 3012 | } |
| 2995 | 3013 | case CU_ORIENTATION_SWAP: |
| 2996 | 3014 | { |
| 2997 | 3015 | bool orientation_swap_xy = |