trunk/src/osd/windows/winmain.c
| r22960 | r22961 | |
| 398 | 398 | { WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "4.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" }, |
| 399 | 399 | /* Bloom below this line */ |
| 400 | 400 | { NULL, NULL, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" }, |
| 401 | { WINOPTION_VECTOR_BLOOM_SCALE, "0.3", OPTION_FLOAT, "Intensity factor for vector bloom" }, |
| 402 | { WINOPTION_RASTER_BLOOM_SCALE, "0.25", OPTION_FLOAT, "Intensity factor for raster bloom" }, |
| 401 | 403 | { WINOPTION_BLOOM_LEVEL0_WEIGHT, "1.0", OPTION_FLOAT, "Bloom level 0 (full-size target) weight" }, |
| 402 | 404 | { WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.21", OPTION_FLOAT, "Bloom level 1 (half-size target) weight" }, |
| 403 | 405 | { WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.19", OPTION_FLOAT, "Bloom level 2 (quarter-size target) weight" }, |
trunk/src/osd/windows/winmain.h
| r22960 | r22961 | |
| 133 | 133 | #define WINOPTION_VECTOR_TIME_PERIOD "vector_time_period" |
| 134 | 134 | #define WINOPTION_VECTOR_LENGTH_SCALE "vector_length_scale" |
| 135 | 135 | #define WINOPTION_VECTOR_LENGTH_RATIO "vector_length_ratio" |
| 136 | #define WINOPTION_VECTOR_BLOOM_SCALE "vector_bloom_scale" |
| 137 | #define WINOPTION_RASTER_BLOOM_SCALE "raster_bloom_scale" |
| 136 | 138 | #define WINOPTION_BLOOM_LEVEL0_WEIGHT "bloom_lvl0_weight" |
| 137 | 139 | #define WINOPTION_BLOOM_LEVEL1_WEIGHT "bloom_lvl1_weight" |
| 138 | 140 | #define WINOPTION_BLOOM_LEVEL2_WEIGHT "bloom_lvl2_weight" |
| r22960 | r22961 | |
| 256 | 258 | float screen_vector_time_period() const { return float_value(WINOPTION_VECTOR_TIME_PERIOD); } |
| 257 | 259 | float screen_vector_length_scale() const { return float_value(WINOPTION_VECTOR_LENGTH_SCALE); } |
| 258 | 260 | float screen_vector_length_ratio() const { return float_value(WINOPTION_VECTOR_LENGTH_RATIO); } |
| 261 | float screen_vector_bloom_scale() const { return float_value(WINOPTION_VECTOR_BLOOM_SCALE); } |
| 262 | float screen_raster_bloom_scale() const { return float_value(WINOPTION_RASTER_BLOOM_SCALE); } |
| 259 | 263 | float screen_bloom_lvl0_weight() const { return float_value(WINOPTION_BLOOM_LEVEL0_WEIGHT); } |
| 260 | 264 | float screen_bloom_lvl1_weight() const { return float_value(WINOPTION_BLOOM_LEVEL1_WEIGHT); } |
| 261 | 265 | float screen_bloom_lvl2_weight() const { return float_value(WINOPTION_BLOOM_LEVEL2_WEIGHT); } |
trunk/src/osd/windows/drawd3d.c
| r22960 | r22961 | |
| 533 | 533 | mame_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)m_texture_max_width, (int)m_texture_max_height); |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | texture_manager::~texture_manager() |
| 537 | { |
| 538 | } |
| 539 | |
| 536 | 540 | void texture_manager::create_resources() |
| 537 | 541 | { |
| 538 | 542 | // experimental: load a PNG to use for vector rendering; it is treated |
| r22960 | r22961 | |
| 997 | 1001 | video_config.waitvsync || video_config.syncrefresh) ? |
| 998 | 1002 | D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; |
| 999 | 1003 | |
| 1004 | printf("m_device is %08x%08x\n", (UINT32)((UINT64)m_device >> 32), (UINT32)((UINT64)m_device & 0x00000000ffffffff)); |
| 1000 | 1005 | // create the D3D device |
| 1001 | 1006 | result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, win_window_list->hwnd, |
| 1002 | 1007 | D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &m_presentation, &m_device); |
trunk/src/osd/windows/d3dhlsl.c
| r22960 | r22961 | |
| 224 | 224 | shaders::~shaders() |
| 225 | 225 | { |
| 226 | 226 | global_free(options); |
| 227 | cache_target *currcache = cachehead; |
| 228 | while(cachehead != NULL) |
| 229 | { |
| 230 | cachehead = currcache->next; |
| 231 | global_free(currcache); |
| 232 | currcache = cachehead; |
| 233 | } |
| 234 | |
| 235 | render_target *currtarget = targethead; |
| 236 | while(targethead != NULL) |
| 237 | { |
| 238 | targethead = currtarget->next; |
| 239 | global_free(currtarget); |
| 240 | currtarget = targethead; |
| 241 | } |
| 227 | 242 | } |
| 228 | 243 | |
| 229 | 244 | |
| r22960 | r22961 | |
| 983 | 998 | options->vector_time_period = winoptions.screen_vector_time_period(); |
| 984 | 999 | options->vector_length_scale = winoptions.screen_vector_length_scale(); |
| 985 | 1000 | options->vector_length_ratio = winoptions.screen_vector_length_ratio(); |
| 1001 | options->vector_bloom_scale = winoptions.screen_vector_bloom_scale(); |
| 1002 | options->raster_bloom_scale = winoptions.screen_raster_bloom_scale(); |
| 986 | 1003 | options->bloom_level0_weight = winoptions.screen_bloom_lvl0_weight(); |
| 987 | 1004 | options->bloom_level1_weight = winoptions.screen_bloom_lvl1_weight(); |
| 988 | 1005 | options->bloom_level2_weight = winoptions.screen_bloom_lvl2_weight(); |
| r22960 | r22961 | |
| 2058 | 2075 | curr_effect = downsample_effect; |
| 2059 | 2076 | |
| 2060 | 2077 | (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->render_texture[2]); |
| 2078 | (*d3dintf->effect.set_float)(curr_effect, "BloomRescale", options->raster_bloom_scale); |
| 2061 | 2079 | |
| 2062 | 2080 | int bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height(); |
| 2063 | 2081 | int bloom_index = 0; |
| r22960 | r22961 | |
| 2222 | 2240 | curr_effect = downsample_effect; |
| 2223 | 2241 | |
| 2224 | 2242 | (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->render_texture[0]); |
| 2243 | (*d3dintf->effect.set_float)(curr_effect, "BloomRescale", options->vector_bloom_scale); |
| 2225 | 2244 | |
| 2226 | 2245 | int bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height(); |
| 2227 | 2246 | int bloom_index = 0; |
| r22960 | r22961 | |
| 2264 | 2283 | |
| 2265 | 2284 | float target_size[2] = { d3d->get_width(), d3d->get_height() }; |
| 2266 | 2285 | (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size); |
| 2286 | float weight0123[4] = { options->bloom_level0_weight, options->bloom_level1_weight, |
| 2287 | options->bloom_level2_weight, options->bloom_level3_weight }; |
| 2288 | float weight4567[4] = { options->bloom_level4_weight, options->bloom_level5_weight, |
| 2289 | options->bloom_level6_weight, options->bloom_level7_weight }; |
| 2290 | float weight89A[3] = { options->bloom_level8_weight, options->bloom_level9_weight, |
| 2291 | options->bloom_level10_weight }; |
| 2292 | (*d3dintf->effect.set_vector)(curr_effect, "Level0123Weight", 4, weight0123); |
| 2293 | (*d3dintf->effect.set_vector)(curr_effect, "Level4567Weight", 4, weight4567); |
| 2294 | (*d3dintf->effect.set_vector)(curr_effect, "Level89AWeight", 3, weight89A); |
| 2267 | 2295 | |
| 2268 | 2296 | (*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->render_texture[0]); |
| 2269 | 2297 | (*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f); |
trunk/hlsl/bloom.fx
| r22960 | r22961 | |
| 189 | 189 | float2 inversePixel = 1.0f / TargetSize; |
| 190 | 190 | float2 TexCoord = Input.Position.xy * inversePixel + float2(0.5f, 0.5f) * inversePixel; |
| 191 | 191 | Output.TexCoord01.xy = TexCoord; |
| 192 | | Output.TexCoord01.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.5f; |
| 193 | | Output.TexCoord23.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.25f; |
| 194 | | Output.TexCoord23.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.125f; |
| 195 | | Output.TexCoord45.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.0625f; |
| 196 | | Output.TexCoord45.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.03125f; |
| 197 | | Output.TexCoord67.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.015625f; |
| 198 | | Output.TexCoord67.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.0078125f; |
| 199 | | Output.TexCoord89.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.00390625f; |
| 200 | | Output.TexCoord89.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.001953125f; |
| 201 | | Output.TexCoordA = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.0009765625f; |
| 192 | Output.TexCoord01.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.5f; |
| 193 | Output.TexCoord23.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.25f; |
| 194 | Output.TexCoord23.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.125f; |
| 195 | Output.TexCoord45.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0625f; |
| 196 | Output.TexCoord45.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.03125f; |
| 197 | Output.TexCoord67.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.015625f; |
| 198 | Output.TexCoord67.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0078125f; |
| 199 | Output.TexCoord89.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.00390625f; |
| 200 | Output.TexCoord89.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.001953125f; |
| 201 | Output.TexCoordA = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0009765625f; |
| 202 | 202 | |
| 203 | 203 | return Output; |
| 204 | 204 | } |
| r22960 | r22961 | |
| 225 | 225 | float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord89.zw).rgb; |
| 226 | 226 | float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoordA).rgb; |
| 227 | 227 | |
| 228 | | texel0 = texel0 * Level0123Weight.x; // 1.0f; |
| 229 | | texel1 = texel1 * Level0123Weight.y; // 0.21f; |
| 230 | | texel2 = texel2 * Level0123Weight.z; // 0.19f; |
| 231 | | texel3 = texel3 * Level0123Weight.w; // 0.17f; |
| 232 | | texel4 = texel4 * Level4567Weight.x; // 0.15f; |
| 233 | | texel5 = texel5 * Level4567Weight.y; // 0.14f; |
| 234 | | texel6 = texel6 * Level4567Weight.z; // 0.13f; |
| 235 | | texel7 = texel7 * Level4567Weight.w; // 0.12f; |
| 236 | | texel8 = texel8 * Level89AWeight.x; // 0.11f; |
| 237 | | texel9 = texel9 * Level89AWeight.y; // 0.10f; |
| 238 | | texelA = texelA * Level89AWeight.z; // 0.09f; |
| 228 | texel0 = texel0 * Level0123Weight.x; |
| 229 | texel1 = texel1 * Level0123Weight.y; |
| 230 | texel2 = texel2 * Level0123Weight.z; |
| 231 | texel3 = texel3 * Level0123Weight.w; |
| 232 | texel4 = texel4 * Level4567Weight.x; |
| 233 | texel5 = texel5 * Level4567Weight.y; |
| 234 | texel6 = texel6 * Level4567Weight.z; |
| 235 | texel7 = texel7 * Level4567Weight.w; |
| 236 | texel8 = texel8 * Level89AWeight.x; |
| 237 | texel9 = texel9 * Level89AWeight.y; |
| 238 | texelA = texelA * Level89AWeight.z; |
| 239 | 239 | |
| 240 | 240 | float4 sum = float4(texel0 + texel1 + texel2 + texel3 + texel4 + |
| 241 | 241 | texel5 + texel6 + texel7 + texel8 + texel9 + texelA, 1.0f); |
trunk/hlsl/downsample.fx
| r22960 | r22961 | |
| 25 | 25 | float4 Color : COLOR0; |
| 26 | 26 | float4 TexCoord01 : TEXCOORD0; |
| 27 | 27 | float4 TexCoord23 : TEXCOORD1; |
| 28 | | float4 TexCoord45 : TEXCOORD2; |
| 29 | | float4 TexCoord67 : TEXCOORD3; |
| 30 | | float4 TexCoord89 : TEXCOORD4; |
| 31 | 28 | }; |
| 32 | 29 | |
| 33 | 30 | struct VS_INPUT |
| r22960 | r22961 | |
| 42 | 39 | float4 Color : COLOR0; |
| 43 | 40 | float4 TexCoord01 : TEXCOORD0; |
| 44 | 41 | float4 TexCoord23 : TEXCOORD1; |
| 45 | | float4 TexCoord45 : TEXCOORD2; |
| 46 | | float4 TexCoord67 : TEXCOORD3; |
| 47 | | float4 TexCoord89 : TEXCOORD4; |
| 48 | 42 | }; |
| 49 | 43 | |
| 50 | 44 | //----------------------------------------------------------------------------- |
| r22960 | r22961 | |
| 53 | 47 | |
| 54 | 48 | uniform float2 TargetSize; |
| 55 | 49 | uniform float2 SourceSize; |
| 50 | uniform float BloomRescale; |
| 56 | 51 | |
| 57 | 52 | VS_OUTPUT vs_main(VS_INPUT Input) |
| 58 | 53 | { |
| r22960 | r22961 | |
| 64 | 59 | Output.Position.xy -= 0.5f; |
| 65 | 60 | Output.Position.xy *= 2.0f; |
| 66 | 61 | Output.Color = Input.Color; |
| 67 | | float2 inversePixel = 1.0f / TargetSize; |
| 68 | | Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.00f + 0.5f, 0.00f + 0.5f) * inversePixel; |
| 69 | | Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(0.50f + 0.5f, 0.00f + 0.5f) * inversePixel; |
| 70 | | Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.25f + 0.5f, 0.25f + 0.5f) * inversePixel; |
| 71 | | Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(0.50f + 0.5f, 0.25f + 0.5f) * inversePixel; |
| 72 | | Output.TexCoord45.xy = Input.Position.xy * inversePixel + float2(0.75f + 0.5f, 0.25f + 0.5f) * inversePixel; |
| 73 | | Output.TexCoord45.zw = Input.Position.xy * inversePixel + float2(0.00f + 0.5f, 0.50f + 0.5f) * inversePixel; |
| 74 | | Output.TexCoord67.xy = Input.Position.xy * inversePixel + float2(0.50f + 0.5f, 0.50f + 0.5f) * inversePixel; |
| 75 | | Output.TexCoord67.zw = Input.Position.xy * inversePixel + float2(0.00f + 0.5f, 0.75f + 0.5f) * inversePixel; |
| 76 | | Output.TexCoord89.xy = Input.Position.xy * inversePixel + float2(0.25f + 0.5f, 0.75f + 0.5f) * inversePixel; |
| 77 | | Output.TexCoord89.zw = Input.Position.xy * inversePixel + float2(0.75f + 0.5f, 0.75f + 0.5f) * inversePixel; |
| 62 | float2 inversePixel = 1.0f / SourceSize; |
| 63 | Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.5f, 0.5f) * inversePixel; |
| 64 | Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(1.5f, 0.5f) * inversePixel; |
| 65 | Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.5f, 1.5f) * inversePixel; |
| 66 | Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(1.5f, 1.5f) * inversePixel; |
| 78 | 67 | |
| 79 | 68 | return Output; |
| 80 | 69 | } |
| r22960 | r22961 | |
| 89 | 78 | float4 texel1 = tex2D(DiffuseSampler, Input.TexCoord01.zw); |
| 90 | 79 | float4 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy); |
| 91 | 80 | float4 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw); |
| 92 | | float4 texel4 = tex2D(DiffuseSampler, Input.TexCoord45.xy); |
| 93 | | float4 texel5 = tex2D(DiffuseSampler, Input.TexCoord45.zw); |
| 94 | | float4 texel6 = tex2D(DiffuseSampler, Input.TexCoord67.xy); |
| 95 | | float4 texel7 = tex2D(DiffuseSampler, Input.TexCoord67.zw); |
| 96 | | float4 texel8 = tex2D(DiffuseSampler, Input.TexCoord89.xy); |
| 97 | | float4 texel9 = tex2D(DiffuseSampler, Input.TexCoord89.zw); |
| 98 | | float4 outTexel = (texel0 + texel1 + texel2 + texel3 + texel4 + texel5 + texel6 + texel7 + texel8 + texel9) * 0.1f; |
| 81 | float4 outTexel = (texel0 + texel1 + texel2 + texel3) * BloomRescale; |
| 99 | 82 | return float4(outTexel.rgb, 1.0f); |
| 100 | 83 | } |
| 101 | 84 | |