summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author Ryan Holtz <rholtz@batcountryentertainment.com>2013-01-21 02:40:48 +0000
committer Ryan Holtz <rholtz@batcountryentertainment.com>2013-01-21 02:40:48 +0000
commitd157249cb74fe849effaef21c1676a8cf17474e4 (patch)
treedb3388ea55fde34ff34e5f9f42da0521ebc6ea5e /src/osd
parent7f3372abf3800e185fa56b51d137e0c47e3357df (diff)
d3dhlsl.c: Add preliminary vector post-processing. [MooglyGuy]
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/windows/d3dcomm.h2
-rw-r--r--src/osd/windows/d3dhlsl.c822
-rw-r--r--src/osd/windows/d3dhlsl.h43
-rw-r--r--src/osd/windows/drawd3d.c230
-rw-r--r--src/osd/windows/drawd3d.h13
-rw-r--r--src/osd/windows/winmain.c9
-rw-r--r--src/osd/windows/winmain.h10
7 files changed, 944 insertions, 185 deletions
diff --git a/src/osd/windows/d3dcomm.h b/src/osd/windows/d3dcomm.h
index 806e4aa7a17..2ac96074006 100644
--- a/src/osd/windows/d3dcomm.h
+++ b/src/osd/windows/d3dcomm.h
@@ -86,6 +86,8 @@ struct d3d_poly_info
UINT32 flags; // rendering flags
DWORD modmode; // texture modulation mode
d3d_texture_info * texture; // pointer to texture info
+ float line_time; // used by vectors
+ float line_length; // used by vectors
};
diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c
index 7cbb665b093..14dc76b55cf 100644
--- a/src/osd/windows/d3dhlsl.c
+++ b/src/osd/windows/d3dhlsl.c
@@ -466,22 +466,6 @@ void hlsl_info::record_texture()
//============================================================
-// hlsl_info::frame_complete
-//============================================================
-
-void hlsl_info::frame_complete()
-{
- if (!master_enable || !d3dintf->post_fx_available)
- return;
-
- if(render_snap && snap_rendered)
- {
- render_snapshot(snap_target);
- }
-}
-
-
-//============================================================
// hlsl_info::end_hlsl_avi_recording
//============================================================
@@ -510,16 +494,20 @@ void hlsl_info::toggle()
{
delete_resources(false);
}
+ master_enable = !master_enable;
}
else
{
if (!initialized)
{
- create_resources(false);
+ bool success = create_resources(false);
+ master_enable = (success ? !master_enable : false);
+ }
+ else
+ {
+ master_enable = !master_enable;
}
}
-
- master_enable = !master_enable;
}
//============================================================
@@ -740,7 +728,6 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window)
snap_width = downcast<windows_options &>(window->machine().options()).d3d_snap_width();
snap_height = downcast<windows_options &>(window->machine().options()).d3d_snap_height();
-
prescale_force_x = 0;
prescale_force_y = 0;
@@ -922,6 +909,18 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window)
ini_file.gets(buf, 1024);
sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count);
+
+ ini_file.gets(buf, 1024);
+ sscanf(buf, "vector_time_scale %f\n", &options->vector_time_scale);
+
+ ini_file.gets(buf, 1024);
+ sscanf(buf, "vector_time_period %f\n", &options->vector_time_period);
+
+ ini_file.gets(buf, 1024);
+ sscanf(buf, "vector_length_scale %f\n", &options->vector_length_scale);
+
+ ini_file.gets(buf, 1024);
+ sscanf(buf, "vector_length_ratio %f\n", &options->vector_length_ratio);
}
}
}
@@ -976,6 +975,10 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window)
options->yiq_q = winoptions.screen_yiq_q();
options->yiq_scan_time = winoptions.screen_yiq_scan_time();
options->yiq_phase_count = winoptions.screen_yiq_phase_count();
+ options->vector_time_scale = winoptions.screen_vector_time_scale();
+ options->vector_time_period = winoptions.screen_vector_time_period();
+ options->vector_length_scale = winoptions.screen_vector_length_scale();
+ options->vector_length_ratio = winoptions.screen_vector_length_ratio();
}
options->params_dirty = true;
@@ -987,70 +990,76 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window)
}
+
//============================================================
// hlsl_info::init_fsfx_quad
//============================================================
void hlsl_info::init_fsfx_quad(void *vertbuf)
{
- if (!master_enable || !d3dintf->post_fx_available)
- return;
+ // Called at the start of each frame by the D3D code in order to reserve two triangles
+ // that are guaranteed to be at a fixed position so as to simply use D3DPT_TRIANGLELIST, 0, 2
+ // instead of having to do bookkeeping about a specific screen quad
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
- d3d_info *d3d = (d3d_info *)window->drawdata;
+ d3d_info *d3d = (d3d_info *)window->drawdata;
- // get a pointer to the vertex buffer
- fsfx_vertices = (d3d_vertex *)vertbuf;
- if (fsfx_vertices == NULL)
- return;
+ // get a pointer to the vertex buffer
+ fsfx_vertices = (d3d_vertex *)vertbuf;
+ if (fsfx_vertices == NULL)
+ return;
- // fill in the vertexes clockwise
- fsfx_vertices[0].x = 0.0f;
- fsfx_vertices[0].y = 0.0f;
- fsfx_vertices[1].x = d3d->width;
- fsfx_vertices[1].y = 0.0f;
- fsfx_vertices[2].x = 0.0f;
- fsfx_vertices[2].y = d3d->height;
- fsfx_vertices[3].x = d3d->width;
- fsfx_vertices[3].y = 0.0f;
- fsfx_vertices[4].x = 0.0f;
- fsfx_vertices[4].y = d3d->height;
- fsfx_vertices[5].x = d3d->width;
- fsfx_vertices[5].y = d3d->height;
+ // fill in the vertexes clockwise
+ fsfx_vertices[0].x = 0.0f;
+ fsfx_vertices[0].y = 0.0f;
+ fsfx_vertices[1].x = d3d->width;
+ fsfx_vertices[1].y = 0.0f;
+ fsfx_vertices[2].x = 0.0f;
+ fsfx_vertices[2].y = d3d->height;
+ fsfx_vertices[3].x = d3d->width;
+ fsfx_vertices[3].y = 0.0f;
+ fsfx_vertices[4].x = 0.0f;
+ fsfx_vertices[4].y = d3d->height;
+ fsfx_vertices[5].x = d3d->width;
+ fsfx_vertices[5].y = d3d->height;
- fsfx_vertices[0].u0 = 0.0f;
- fsfx_vertices[0].v0 = 0.0f;
+ fsfx_vertices[0].u0 = 0.0f;
+ fsfx_vertices[0].v0 = 0.0f;
- fsfx_vertices[1].u0 = 1.0f;
- fsfx_vertices[1].v0 = 0.0f;
+ fsfx_vertices[1].u0 = 1.0f;
+ fsfx_vertices[1].v0 = 0.0f;
- fsfx_vertices[2].u0 = 0.0f;
- fsfx_vertices[2].v0 = 1.0f;
+ fsfx_vertices[2].u0 = 0.0f;
+ fsfx_vertices[2].v0 = 1.0f;
- fsfx_vertices[3].u0 = 1.0f;
- fsfx_vertices[3].v0 = 0.0f;
+ fsfx_vertices[3].u0 = 1.0f;
+ fsfx_vertices[3].v0 = 0.0f;
- fsfx_vertices[4].u0 = 0.0f;
- fsfx_vertices[4].v0 = 1.0f;
+ fsfx_vertices[4].u0 = 0.0f;
+ fsfx_vertices[4].v0 = 1.0f;
- fsfx_vertices[5].u0 = 1.0f;
- fsfx_vertices[5].v0 = 1.0f;
+ fsfx_vertices[5].u0 = 1.0f;
+ fsfx_vertices[5].v0 = 1.0f;
- // set the color, Z parameters to standard values
- for (int i = 0; i < 6; i++)
- {
- fsfx_vertices[i].z = 0.0f;
- fsfx_vertices[i].rhw = 1.0f;
- fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
- }
+ // set the color, Z parameters to standard values
+ for (int i = 0; i < 6; i++)
+ {
+ fsfx_vertices[i].z = 0.0f;
+ fsfx_vertices[i].rhw = 1.0f;
+ fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
+ }
}
+
//============================================================
// hlsl_info::create_resources
//============================================================
int hlsl_info::create_resources(bool reset)
{
+ printf("create_resources enter\n"); fflush(stdout);
initialized = true;
if (!master_enable || !d3dintf->post_fx_available)
@@ -1058,7 +1067,24 @@ int hlsl_info::create_resources(bool reset)
d3d_info *d3d = (d3d_info *)window->drawdata;
- HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture);
+ HRESULT result = (*d3dintf->device.get_render_target)(d3d->device, 0, &backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, 4, 4, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &black_texture);
+ if (result != D3D_OK)
+ {
+ mame_printf_verbose("Direct3D: Unable to init video-memory target for black texture (%08x)\n", (UINT32)result);
+ return 1;
+ }
+ (*d3dintf->texture.get_surface_level)(black_texture, 0, &black_surface);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, black_surface);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
+ result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture);
if (result != D3D_OK)
{
mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
@@ -1091,6 +1117,8 @@ int hlsl_info::create_resources(bool reset)
shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
}
+ printf("load shaders enter\n"); fflush(stdout);
+
const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir();
// Replace all this garbage with a proper data-driven system
@@ -1216,9 +1244,35 @@ int hlsl_info::create_resources(bool reset)
// create the vector shader
#if HLSL_VECTOR
- char vector_cstr[1024];
- sprintf(vector_cstr, "%s\\vector.fx", fx_dir);
- TCHAR *vector_name = tstring_from_utf8(vector_cstr);
+ char bloom_cstr[1024];
+ sprintf(bloom_cstr, "%s\\bloom.fx", fx_dir);
+ TCHAR *bloom_name = tstring_from_utf8(bloom_cstr);
+
+ result = (*d3dintf->device.create_effect)(d3d->device, bloom_name, &bloom_effect);
+ if(result != D3D_OK)
+ {
+ mame_printf_verbose("Direct3D: Unable to load bloom.fx\n");
+ return 1;
+ }
+ if (bloom_name)
+ osd_free(bloom_name);
+
+ char downsample_cstr[1024];
+ sprintf(downsample_cstr, "%s\\downsample.fx", fx_dir);
+ TCHAR *downsample_name = tstring_from_utf8(downsample_cstr);
+
+ result = (*d3dintf->device.create_effect)(d3d->device, downsample_name, &downsample_effect);
+ if(result != D3D_OK)
+ {
+ mame_printf_verbose("Direct3D: Unable to load downsample.fx\n");
+ return 1;
+ }
+ if (downsample_name)
+ osd_free(downsample_name);
+
+ char vector_cstr[1024];
+ sprintf(vector_cstr, "%s\\vector.fx", fx_dir);
+ TCHAR *vector_name = tstring_from_utf8(vector_cstr);
result = (*d3dintf->device.create_effect)(d3d->device, vector_name, &vector_effect);
if(result != D3D_OK)
@@ -1251,15 +1305,17 @@ int hlsl_info::create_resources(bool reset)
if (yiq_decode_name)
osd_free(yiq_decode_name);
+ printf("load shaders exit\n"); fflush(stdout);
+
return 0;
}
//============================================================
-// hlsl_info::begin
+// hlsl_info::begin_draw
//============================================================
-void hlsl_info::begin()
+void hlsl_info::begin_draw()
{
if (!master_enable || !d3dintf->post_fx_available)
return;
@@ -1284,6 +1340,172 @@ void hlsl_info::begin()
//============================================================
+// hlsl_info::begin_frame
+//============================================================
+
+void hlsl_info::begin_frame()
+{
+ record_texture();
+
+ /*d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
+ if (rt == NULL)
+ {
+ return;
+ }
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);*/
+}
+
+
+//============================================================
+// hlsl_info::blit
+//============================================================
+
+void hlsl_info::blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst, D3DPRIMITIVETYPE prim_type,
+ UINT32 prim_index, UINT32 prim_count, int dstw, int dsth)
+{
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, dst);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
+ curr_effect = effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", src);
+
+ (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)dstw);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)dsth);
+ (*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion);
+ (*d3dintf->effect.set_float)(curr_effect, "Brighten", 0.0f);
+
+ unsigned int num_passes = 0;
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, prim_type, prim_index, prim_count);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+
+ if (new_dst)
+ {
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, new_dst);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ }
+}
+
+
+
+//============================================================
+// hlsl_info::blit
+//============================================================
+
+void hlsl_info::blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst, D3DPRIMITIVETYPE prim_type,
+ UINT32 prim_index, UINT32 prim_count)
+{
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, dst);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
+ curr_effect = effect;
+
+ d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
+ if (rt == NULL)
+ {
+ return;
+ }
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", src);
+
+ (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
+ (*d3dintf->effect.set_float)(curr_effect, "ScreenWidth", (float)d3d->width);
+ (*d3dintf->effect.set_float)(curr_effect, "ScreenHeight", (float)d3d->height);
+ (*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion);
+ (*d3dintf->effect.set_float)(curr_effect, "Brighten", 1.0f);
+
+ unsigned int num_passes = 0;
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, prim_type, prim_index, prim_count);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+
+ (*d3dintf->effect.set_float)(curr_effect, "Brighten", 0.0f);
+
+ if (new_dst)
+ {
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, new_dst);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ }
+}
+
+//============================================================
+// hlsl_info::end_frame
+//============================================================
+
+void hlsl_info::end_frame()
+{
+ if (!master_enable || !d3dintf->post_fx_available)
+ return;
+
+ if(render_snap && snap_rendered)
+ {
+ render_snapshot(snap_target);
+ }
+
+ if (!lines_pending)
+ return;
+
+ lines_pending = false;
+ /*d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
+ if (!rt)
+ return;
+
+ blit(backbuffer, rt->texture[0], NULL, vecbuf_type, vecbuf_index, vecbuf_count);*/
+
+ /*d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
+ if (rt == NULL)
+ {
+ return;
+ }
+
+ blit(backbuffer, rt->texture[1], NULL, vecbuf_type, vecbuf_index, vecbuf_count);
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);*/
+}
+
+
+//============================================================
// hlsl_info::init_effect_info
//============================================================
@@ -1313,8 +1535,6 @@ void hlsl_info::init_effect_info(d3d_poly_info *poly)
(*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
(*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
(*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
- (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
(*d3dintf->effect.set_vector)(curr_effect, "Floor", 3, options->floor);
(*d3dintf->effect.set_float)(curr_effect, "SnapX", snap_width);
(*d3dintf->effect.set_float)(curr_effect, "SnapY", snap_height);
@@ -1414,16 +1634,6 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
UINT num_passes = 0;
d3d_info *d3d = (d3d_info *)window->drawdata;
-#if HLSL_VECTOR
- if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable)
- {
- lines_pending = true;
- }
- else if (PRIMFLAG_GET_VECTORBUF(poly->flags) && vector_enable)
- {
- }
-#endif
-
if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags) && poly->texture != NULL)
{
d3d_render_target *rt = find_render_target(poly->texture);
@@ -1644,12 +1854,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
(*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
(*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
(*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[0]);
- (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
@@ -1675,12 +1880,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
(*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
(*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f);
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f);
- (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[0]);
- (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
+ (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[1]);
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
@@ -1708,10 +1908,6 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
{
(*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
(*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
(*d3dintf->effect.set_vector)(curr_effect, "Phosphor", 3, options->phosphor);
}
(*d3dintf->effect.set_float)(curr_effect, "TextureWidth", (float)rt->target_width);
@@ -1764,11 +1960,13 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
(*d3dintf->effect.end)(curr_effect);
+ curr_effect = post_effect;
+ (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
+
/* Scanlines and shadow mask, at high res for AVI logging*/
if(avi_output_file != NULL)
{
- curr_effect = post_effect;
-
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
result = (*d3dintf->device.set_render_target)(d3d->device, 0, avi_final_target);
@@ -1790,8 +1988,6 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
if(render_snap)
{
- curr_effect = post_effect;
-
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
result = (*d3dintf->device.set_render_target)(d3d->device, 0, snap_target);
@@ -1813,13 +2009,329 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
snap_rendered = true;
}
- /* Scanlines and shadow mask */
- curr_effect = post_effect;
+ /* Scanlines and shadow mask */
+ curr_effect = post_effect;
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
- result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
- if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)rt->target_width);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)rt->target_height);
+
+#if HLSL_VECTOR
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]);
+#else
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+#endif
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+
+#if HLSL_VECTOR
+ /* Bloom */
+ curr_effect = downsample_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[1]);
+
+ int bloom_size = (rt->target_width < rt->target_height) ? rt->target_width : rt->target_height;
+ int bloom_index = 0;
+ int bloom_width = rt->target_width;
+ int bloom_height = rt->target_height;
+ for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
+ {
+ float source_size[2] = { bloom_width, bloom_height };
+ float target_size[2] = { bloom_width >> 1, bloom_height >> 1 };
+ (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
+ (*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size);
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", (bloom_index == 0) ? rt->texture[1] : ct->bloom_texture[bloom_index - 1]);
+
+ if (ct->bloom_target[bloom_index] == NULL)
+ {
+ (*d3dintf->effect.end)(curr_effect);
+ break;
+ }
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, ct->bloom_target[bloom_index]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 7:%d\n", (int)result, bloom_size);
+ //result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ //if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+
+ bloom_index++;
+ bloom_width >>= 1;
+ bloom_height >>= 1;
+ }
+
+ /* Bloom composite pass*/
+ curr_effect = bloom_effect;
+
+ float target_size[2] = { rt->target_width, rt->target_height };
+ (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->texture[1]);
+ (*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f);
+
+ char name[9] = "Diffuse*";
+ char scale[14] = "DiffuseScale*";
+ for(int index = 1; index < bloom_index; index++)
+ {
+ name[7] = 'A' + index;
+ scale[12] = 'A' + index;
+ (*d3dintf->effect.set_texture)(curr_effect, name, ct->bloom_texture[index - 1]);
+ (*d3dintf->effect.set_float)(curr_effect, scale, 1.0f);
+ }
+ for(int index = bloom_index; index < 11; index++)
+ {
+ name[7] = 'A' + index;
+ scale[12] = 'A' + index;
+ (*d3dintf->effect.set_texture)(curr_effect, name, black_texture);
+ (*d3dintf->effect.set_float)(curr_effect, scale, 0.0f);
+ }
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[2]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 8\n", (int)result);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+
+ curr_effect = effect;
+
+ //(*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f);
+
+ //blit(backbuffer, ct->last_texture, NULL, poly->type, vertnum, poly->count, d3d->width, d3d->height);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 9\n", (int)result);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[2]);
+
+ (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
+ (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion);
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+#endif
+
+ poly->texture->cur_frame++;
+ poly->texture->cur_frame %= options->yiq_phase_count;
+
+ options->params_dirty = false;
+ }
+#if HLSL_VECTOR
+ else if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable)
+ {
+ d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
+ if (rt == NULL)
+ {
+ return;
+ }
+
+ lines_pending = true;
+
+ curr_effect = vector_effect;
+ //curr_effect = effect;
+
+ if(options->params_dirty)
+ {
+ (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
+ }
+
+ float time_params[2] = { poly->line_time, options->vector_time_scale };
+ float length_params[3] = { poly->line_length, options->vector_length_scale, options->vector_length_ratio };
+ (*d3dintf->effect.set_vector)(curr_effect, "TimeParams", 2, time_params);
+ (*d3dintf->effect.set_vector)(curr_effect, "LengthParams", 3, length_params);
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
+ curr_effect = effect;
+
+ (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
+ }
+ else if (PRIMFLAG_GET_VECTORBUF(poly->flags) && vector_enable)
+ {
+ //if (!lines_pending)
+ //return;
+ //lines_pending = false;
+
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
+ d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
+ if (rt == NULL)
+ {
+ return;
+ }
+
+ /* Bloom */
+ curr_effect = downsample_effect;
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
+
+ int bloom_size = (d3d->width < d3d->height) ? d3d->width : d3d->height;
+ int bloom_index = 0;
+ int bloom_width = d3d->width;
+ int bloom_height = d3d->height;
+ for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
+ {
+ float source_size[2] = { bloom_width, bloom_height };
+ float target_size[2] = { bloom_width >> 1, bloom_height >> 1 };
+ (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
+ (*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size);
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", (bloom_index == 0) ? rt->texture[0] : rt->bloom_texture[bloom_index - 1]);
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->bloom_target[bloom_index]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
+ //result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ //if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+
+ bloom_index++;
+ bloom_width >>= 1;
+ bloom_height >>= 1;
+ }
+
+ /* Bloom composite pass*/
+ curr_effect = bloom_effect;
+
+ float target_size[2] = { d3d->width, d3d->height };
+ (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->texture[0]);
+ (*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f);
+
+ char name[9] = "Diffuse*";
+ char scale[14] = "DiffuseScale*";
+ for(int index = 1; index < bloom_index; index++)
+ {
+ name[7] = 'A' + index;
+ scale[12] = 'A' + index;
+ (*d3dintf->effect.set_texture)(curr_effect, name, rt->bloom_texture[index - 1]);
+ (*d3dintf->effect.set_float)(curr_effect, scale, 1.0f);
+ }
+ for(int index = bloom_index; index < 11; index++)
+ {
+ name[7] = 'A' + index;
+ scale[12] = 'A' + index;
+ (*d3dintf->effect.set_texture)(curr_effect, name, black_texture);
+ (*d3dintf->effect.set_float)(curr_effect, scale, 0.0f);
+ }
+
+ (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
+
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
+ //result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ //if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+
+ for (UINT pass = 0; pass < num_passes; pass++)
+ {
+ (*d3dintf->effect.begin_pass)(curr_effect, pass);
+ // add the primitives
+ result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
+ (*d3dintf->effect.end_pass)(curr_effect);
+ }
+
+ (*d3dintf->effect.end)(curr_effect);
+
+ /* Phosphor */
+ curr_effect = phosphor_effect;
+
+ if(options->params_dirty)
+ {
+ (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
+ (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
+ (*d3dintf->effect.set_vector)(curr_effect, "Phosphor", 3, options->phosphor);
+ }
+ (*d3dintf->effect.set_float)(curr_effect, "TextureWidth", (float)d3d->width);
+ (*d3dintf->effect.set_float)(curr_effect, "TextureHeight", (float)d3d->height);
+ (*d3dintf->effect.set_float)(curr_effect, "Passthrough", 0.0f);
+
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[1]);
+ (*d3dintf->effect.set_texture)(curr_effect, "LastPass", rt->texture[2]);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 4\n", (int)result);
+ result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
(*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
@@ -1827,29 +2339,38 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
{
(*d3dintf->effect.begin_pass)(curr_effect, pass);
// add the primitives
- result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
+ result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
(*d3dintf->effect.end_pass)(curr_effect);
}
(*d3dintf->effect.end)(curr_effect);
- poly->texture->cur_frame++;
- poly->texture->cur_frame %= options->yiq_phase_count;
+ curr_effect = effect;
- options->params_dirty = false;
- }
-#if HLSL_VECTOR
- else if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable)
- {
- }
+ //blit(backbuffer, rt->bloom_texture[5], NULL, poly->type, vertnum, poly->count);
+ blit(rt->target[2], rt->texture[0], NULL, poly->type, vertnum, poly->count);
+ blit(backbuffer, rt->texture[0], NULL, poly->type, vertnum, poly->count);
+ //blit(backbuffer, rt->texture[0], NULL, poly->type, vertnum, poly->count);
+
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
+ vecbuf_type = poly->type;
+ vecbuf_index = vertnum;
+ vecbuf_count = poly->count;
+ }
#endif
else
{
- (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
- (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
- (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
- (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "RawWidth", d3d->width);//poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "RawHeight", d3d->height);//poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f);//poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
+ (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f);//poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
(*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
(*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
(*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f);
@@ -1873,10 +2394,10 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum)
//============================================================
-// hlsl_info::end
+// hlsl_info::end_draw
//============================================================
-void hlsl_info::end()
+void hlsl_info::end_draw()
{
if (!master_enable || !d3dintf->post_fx_available)
return;
@@ -1902,14 +2423,22 @@ bool hlsl_info::add_cache_target(d3d_info* d3d, d3d_texture_info* info, int widt
{
d3d_cache_target* target = (d3d_cache_target*)global_alloc_clear(d3d_cache_target);
- if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale))
+ if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale, true))
{
global_free(target);
return false;
}
- target->width = info->texinfo.width;
- target->height = info->texinfo.height;
+ if (info != NULL)
+ {
+ target->width = info->texinfo.width;
+ target->height = info->texinfo.height;
+ }
+ else
+ {
+ target->width = d3d->width;
+ target->height = d3d->height;
+ }
target->next = cachehead;
target->prev = NULL;
@@ -1925,7 +2454,7 @@ bool hlsl_info::add_cache_target(d3d_info* d3d, d3d_texture_info* info, int widt
return true;
}
-d3d_render_target* hlsl_info::get_vector_target(d3d_info *d3d)
+d3d_render_target* hlsl_info::get_vector_target()
{
#if HLSL_VECTOR
if (!vector_enable)
@@ -1933,15 +2462,18 @@ d3d_render_target* hlsl_info::get_vector_target(d3d_info *d3d)
return false;
}
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+
return find_render_target(d3d->width, d3d->height, 0, 0);
#endif
return NULL;
}
-void hlsl_info::create_vector_target(d3d_info *d3d, render_primitive *prim)
+void hlsl_info::create_vector_target(render_primitive *prim)
{
#if HLSL_VECTOR
- if (!add_render_target(d3d, NULL, d3d->width, d3d->height, 1, 1))
+ d3d_info *d3d = (d3d_info *)window->drawdata;
+ if (!add_render_target(d3d, NULL, d3d->width, d3d->height, 1, 1, true))
{
vector_enable = false;
}
@@ -1952,25 +2484,34 @@ void hlsl_info::create_vector_target(d3d_info *d3d, render_primitive *prim)
// hlsl_info::add_render_target - register a render target
//============================================================
-bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale)
+bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, bool bloom)
{
UINT32 screen_index = 0;
UINT32 page_index = 0;
if (info != NULL)
{
- if (find_render_target(info))
+ d3d_render_target *existing_target = find_render_target(info);
+ if (existing_target != NULL)
{
- remove_render_target(info);
+ remove_render_target(existing_target);
}
UINT32 screen_index_data = (UINT32)info->texinfo.osddata;
screen_index = screen_index_data >> 1;
page_index = screen_index_data & 1;
}
+ else
+ {
+ d3d_render_target *existing_target = find_render_target(d3d->width, d3d->height, 0, 0);
+ if (existing_target != NULL)
+ {
+ remove_render_target(existing_target);
+ }
+ }
d3d_render_target* target = (d3d_render_target*)global_alloc_clear(d3d_render_target);
- if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale))
+ if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale, bloom))
{
global_free(target);
return false;
@@ -1987,6 +2528,13 @@ bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int wid
target->height = d3d->height;
}
+ HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, target->target[0]);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+ result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
+ result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
+ if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
+
target->screen_index = screen_index;
target->page_index = page_index;
@@ -2145,6 +2693,10 @@ void hlsl_info::delete_resources(bool reset)
file.printf("yiq_q %f\n", options->yiq_q);
file.printf("yiq_scan_time %f\n", options->yiq_scan_time);
file.printf("yiq_phase_count %d\n", options->yiq_phase_count);
+ file.printf("vector_time_scale %f\n", options->vector_time_scale);
+ file.printf("vector_time_period %f\n", options->vector_time_period);
+ file.printf("vector_length_scale %f\n", options->vector_length_scale);
+ file.printf("vector_length_ratio %f\n", options->vector_length_ratio);
}
while (targethead != NULL)
@@ -2152,6 +2704,18 @@ void hlsl_info::delete_resources(bool reset)
remove_render_target(targethead);
}
+#if HLSL_VECTOR
+ if (downsample_effect != NULL)
+ {
+ (*d3dintf->effect.release)(downsample_effect);
+ downsample_effect = NULL;
+ }
+ if (bloom_effect != NULL)
+ {
+ (*d3dintf->effect.release)(bloom_effect);
+ bloom_effect = NULL;
+ }
+#endif
if (effect != NULL)
{
(*d3dintf->effect.release)(effect);
@@ -2203,6 +2767,12 @@ void hlsl_info::delete_resources(bool reset)
yiq_decode_effect = NULL;
}
+ if (black_texture != NULL)
+ {
+ (*d3dintf->texture.release)(black_texture);
+ black_texture = NULL;
+ }
+
if (avi_copy_texture != NULL)
{
(*d3dintf->texture.release)(avi_copy_texture);
diff --git a/src/osd/windows/d3dhlsl.h b/src/osd/windows/d3dhlsl.h
index 52bad0062ad..7d508ddb2a1 100644
--- a/src/osd/windows/d3dhlsl.h
+++ b/src/osd/windows/d3dhlsl.h
@@ -48,7 +48,7 @@
// CONSTANTS
//============================================================
-#define HLSL_VECTOR (0)
+#define HLSL_VECTOR (0)
//============================================================
// TYPE DEFINITIONS
@@ -91,6 +91,8 @@ struct hlsl_options
float floor[3];
float phosphor[3];
float saturation;
+
+ // NTSC
bool yiq_enable;
float yiq_cc;
float yiq_a;
@@ -103,6 +105,12 @@ struct hlsl_options
float yiq_q;
float yiq_scan_time;
int yiq_phase_count;
+
+ // Vectors
+ float vector_time_scale;
+ float vector_time_period;
+ float vector_length_scale;
+ float vector_length_ratio;
};
class hlsl_info
@@ -113,23 +121,26 @@ public:
~hlsl_info();
void init(d3d_base *d3dintf, win_window_info *window);
- void init_fsfx_quad(void *vertbuf);
bool enabled() { return master_enable; }
void toggle();
- bool vector_enabled() { return vector_enable && (bool)HLSL_VECTOR; }
- d3d_render_target* get_vector_target(d3d_info *d3d);
- void create_vector_target(d3d_info *d3d, render_primitive *prim);
+ bool vector_enabled() { return master_enable && vector_enable && (bool)HLSL_VECTOR; }
+ d3d_render_target* get_vector_target();
+ void create_vector_target(render_primitive *prim);
+
+ void begin_frame();
+ void end_frame();
+
+ void begin_draw();
+ void end_draw();
- void begin();
void init_effect_info(d3d_poly_info *poly);
void render_quad(d3d_poly_info *poly, int vertnum);
- void end();
bool register_texture(d3d_texture_info *texture);
bool register_prescaled_texture(d3d_texture_info *texture);
- bool add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale);
+ bool add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, bool bloom = false);
bool add_cache_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, int screen_index);
void window_save();
@@ -139,8 +150,7 @@ public:
void avi_update_snap(d3d_surface *surface);
void render_snapshot(d3d_surface *surface);
void record_texture();
-
- void frame_complete();
+ void init_fsfx_quad(void *vertbuf);
void set_texture(d3d_texture_info *texture);
d3d_render_target * find_render_target(d3d_texture_info *info);
@@ -155,6 +165,11 @@ public:
slider_state *init_slider_list();
private:
+ void blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst,
+ D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count,
+ int dstw, int dsth);
+ void blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst,
+ D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count);
void enumerate_screens();
void end_avi_recording();
@@ -186,6 +201,9 @@ private:
bitmap_argb32 shadow_bitmap; // shadow mask bitmap for post-processing shader
d3d_texture_info * shadow_texture; // shadow mask texture for post-processing shader
hlsl_options * options; // current uniform state
+ D3DPRIMITIVETYPE vecbuf_type;
+ UINT32 vecbuf_index;
+ UINT32 vecbuf_count;
avi_file * avi_output_file; // AVI file
bitmap_rgb32 avi_snap; // AVI snapshot
@@ -197,6 +215,9 @@ private:
d3d_surface * avi_final_target; // AVI upscaled surface
d3d_texture * avi_final_texture; // AVI upscaled texture
+ d3d_surface * black_surface; // black dummy surface
+ d3d_texture * black_texture; // black dummy texture
+
bool render_snap; // whether or not to take HLSL post-render snapshot
bool snap_rendered; // whether we just rendered our HLSL post-render shot or not
d3d_surface * snap_copy_target; // snapshot destination surface in system memory
@@ -223,6 +244,8 @@ private:
d3d_effect * yiq_encode_effect; // pointer to the YIQ encoder effect object
d3d_effect * yiq_decode_effect; // pointer to the YIQ decoder effect object
#if HLSL_VECTOR
+ d3d_effect * bloom_effect; // pointer to the bloom composite effect
+ d3d_effect * downsample_effect; // pointer to the bloom downsample effect
d3d_effect * vector_effect; // pointer to the vector-effect object
#endif
d3d_vertex * fsfx_vertices; // pointer to our full-screen-quad object
diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c
index 6d9572685a0..a8d4949cbd4 100644
--- a/src/osd/windows/drawd3d.c
+++ b/src/osd/windows/drawd3d.c
@@ -365,7 +365,7 @@ static void pick_best_mode(win_window_info *window);
static int update_window_size(win_window_info *window);
// drawing
-static void draw_line(d3d_info *d3d, const render_primitive *prim);
+static void draw_line(d3d_info *d3d, const render_primitive *prim, float line_time);
static void draw_quad(d3d_info *d3d, const render_primitive *prim);
// primitives
@@ -499,6 +499,7 @@ static void drawd3d_window_save(win_window_info *window)
}
+
//============================================================
// drawd3d_window_destroy
//============================================================
@@ -598,7 +599,7 @@ mtlog_add("drawd3d_window_draw: begin");
result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
- d3d->hlsl->record_texture();
+ d3d->hlsl->begin_frame();
// first update any textures
window->primlist->acquire_lock();
@@ -610,9 +611,9 @@ mtlog_add("drawd3d_window_draw: begin");
}
else if(d3d->hlsl->vector_enabled() && PRIMFLAG_GET_VECTORBUF(prim->flags))
{
- if (!d3d->hlsl->get_vector_target(d3d))
+ if (!d3d->hlsl->get_vector_target())
{
- d3d->hlsl->create_vector_target(d3d, prim);
+ d3d->hlsl->create_vector_target(prim);
}
}
}
@@ -624,19 +625,46 @@ mtlog_add("drawd3d_window_draw: begin_scene");
d3d->lockedbuf = NULL;
- // loop over primitives
- if(d3d->hlsl->enabled())
- {
- d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
- d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
- }
+ // loop over primitives
+ if(d3d->hlsl->enabled())
+ {
+ d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
+ d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
+ }
+
+mtlog_add("drawd3d_window_draw: count lines");
+ int line_count = 0;
+ for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
+ if (prim->type == render_primitive::LINE && PRIMFLAG_GET_VECTOR(prim->flags))
+ line_count++;
mtlog_add("drawd3d_window_draw: primitive loop begin");
+ // Rotating index for vector time offsets
+ static int start_index = 0;
+ int line_index = 0;
+ windows_options &options = downcast<windows_options &>(window->machine().options());
+ float period = options.screen_vector_time_period();
for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
+ {
switch (prim->type)
{
case render_primitive::LINE:
- draw_line(d3d, prim);
+ if (PRIMFLAG_GET_VECTOR(prim->flags))
+ {
+ if (period == 0.0f || line_count == 0)
+ {
+ draw_line(d3d, prim, 1.0f);
+ }
+ else
+ {
+ draw_line(d3d, prim, (float)(start_index + line_index) / ((float)line_count * period));
+ line_index++;
+ }
+ }
+ else
+ {
+ draw_line(d3d, prim, 0.0f);
+ }
break;
case render_primitive::QUAD:
@@ -646,6 +674,12 @@ mtlog_add("drawd3d_window_draw: primitive loop begin");
default:
throw emu_fatalerror("Unexpected render_primitive type");
}
+ }
+ start_index += (int)((float)line_index * period);
+ if (line_count > 0)
+ {
+ start_index %= line_count;
+ }
mtlog_add("drawd3d_window_draw: primitive loop end");
window->primlist->release_lock();
@@ -654,6 +688,8 @@ mtlog_add("drawd3d_window_draw: flush_pending begin");
primitive_flush_pending(d3d);
mtlog_add("drawd3d_window_draw: flush_pending end");
+ d3d->hlsl->end_frame();
+
// finish the scene
mtlog_add("drawd3d_window_draw: end_scene begin");
result = (*d3dintf->device.end_scene)(d3d->device);
@@ -666,8 +702,6 @@ mtlog_add("drawd3d_window_draw: present begin");
mtlog_add("drawd3d_window_draw: present end");
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device present call\n", (int)result);
- d3d->hlsl->frame_complete();
-
return 0;
}
@@ -1446,7 +1480,7 @@ static int update_window_size(win_window_info *window)
// draw_line
//============================================================
-static void draw_line(d3d_info *d3d, const render_primitive *prim)
+static void draw_line(d3d_info *d3d, const render_primitive *prim, float line_time)
{
const line_aa_step *step = line_aa_4step;
render_bounds b0, b1;
@@ -1546,6 +1580,22 @@ static void draw_line(d3d_info *d3d, const render_primitive *prim)
poly->flags = prim->flags;
poly->modmode = D3DTOP_MODULATE;
poly->texture = d3d->vector_texture;
+ poly->line_time = line_time;
+ poly->line_length = 1.0f;
+ if (PRIMFLAG_GET_VECTOR(poly->flags))
+ {
+ float dx = fabs(prim->bounds.x1 - prim->bounds.x0);
+ float dy = fabs(prim->bounds.y1 - prim->bounds.y0);
+ float length2 = dx * dx + dy * dy;
+ if (length2 > 0.0f)
+ {
+ poly->line_length = sqrt(length2);
+ }
+ else
+ {
+ // use default length of 1.0f from above
+ }
+ }
}
}
@@ -1640,6 +1690,7 @@ static void draw_quad(d3d_info *d3d, const render_primitive *prim)
poly->flags = prim->flags;
poly->modmode = modmode;
poly->texture = texture;
+ //poly->
}
@@ -1653,8 +1704,16 @@ static d3d_vertex *primitive_alloc(d3d_info *d3d, int numverts)
// if we're going to overflow, flush
if (d3d->lockedbuf != NULL && d3d->numverts + numverts >= VERTEX_BUFFER_SIZE)
+ {
primitive_flush_pending(d3d);
+ if(d3d->hlsl->enabled())
+ {
+ d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
+ d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
+ }
+ }
+
// if we don't have a lock, grab it now
if (d3d->lockedbuf == NULL)
{
@@ -1698,17 +1757,16 @@ static void primitive_flush_pending(d3d_info *d3d)
result = (*d3dintf->device.set_stream_source)(d3d->device, 0, d3d->vertexbuf, sizeof(d3d_vertex));
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_stream_source call\n", (int)result);
- d3d->hlsl->begin();
+ d3d->hlsl->begin_draw();
- // first remember the original render target in case we need to set a new one
- if(d3d->hlsl->enabled() && d3dintf->post_fx_available)
- {
- vertnum = 6;
- }
- else
- {
- vertnum = 0;
- }
+ if (d3d->hlsl->enabled())
+ {
+ vertnum = 6;
+ }
+ else
+ {
+ vertnum = 0;
+ }
// now do the polys
for (polynum = 0; polynum < d3d->numpolys; polynum++)
@@ -1753,7 +1811,7 @@ static void primitive_flush_pending(d3d_info *d3d)
vertnum += poly->numverts;
}
- d3d->hlsl->end();
+ d3d->hlsl->end_draw();
// reset the vertex count
d3d->numverts = 0;
@@ -2660,6 +2718,20 @@ static void texture_update(d3d_info *d3d, const render_primitive *prim)
d3d_cache_target::~d3d_cache_target()
{
+ for (int index = 0; index < 11; index++)
+ {
+ if (bloom_texture[index] != NULL)
+ {
+ (*d3dintf->texture.release)(bloom_texture[index]);
+ bloom_texture[index] = NULL;
+ }
+ if (bloom_target[index] != NULL)
+ {
+ (*d3dintf->surface.release)(bloom_target[index]);
+ bloom_target[index] = NULL;
+ }
+ }
+
if (last_texture != NULL)
{
(*d3dintf->texture.release)(last_texture);
@@ -2677,13 +2749,37 @@ d3d_cache_target::~d3d_cache_target()
// d3d_cache_target::init - initializes a target cache
//============================================================
-bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y)
+bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom)
{
+ if (bloom)
+ {
+ int bloom_size = (width * prescale_x < height * prescale_y) ? width * prescale_x : height * prescale_y;
+ int bloom_index = 0;
+ int bloom_width = width * prescale_x;
+ int bloom_height = height * prescale_y;
+ for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
+ {
+ printf("%d: %d, %d\n", bloom_index, bloom_width, bloom_height);
+ bloom_width >>= 1;
+ bloom_height >>= 1;
+ HRESULT result = (*d3dintf->device.create_texture)(d3d->device, bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
+ if (result != D3D_OK)
+ {
+ return false;
+ }
+ (*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
+ bloom_index++;
+ }
+ }
+
HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture);
if (result != D3D_OK)
return false;
(*d3dintf->texture.get_surface_level)(last_texture, 0, &last_target);
+ target_width = width * prescale_x;
+ target_height = height * prescale_y;
+
return true;
}
@@ -2693,6 +2789,20 @@ bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int hei
d3d_render_target::~d3d_render_target()
{
+ for (int index = 0; index < 11; index++)
+ {
+ if (bloom_texture[index] != NULL)
+ {
+ (*d3dintf->texture.release)(bloom_texture[index]);
+ bloom_texture[index] = NULL;
+ }
+ if (bloom_target[index] != NULL)
+ {
+ (*d3dintf->surface.release)(bloom_target[index]);
+ bloom_target[index] = NULL;
+ }
+ }
+
for (int index = 0; index < 5; index++)
{
if (texture[index] != NULL)
@@ -2735,42 +2845,70 @@ d3d_render_target::~d3d_render_target()
// d3d_render_target::init - initializes a render target
//============================================================
-bool d3d_render_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y)
+bool d3d_render_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom)
{
- HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[0]);
+ D3DFORMAT format = bloom ? D3DFMT_A16B16G16R16F : D3DFMT_A8R8G8B8;
+
+ HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[0]);
if (result != D3D_OK)
return false;
(*d3dintf->texture.get_surface_level)(texture[0], 0, &target[0]);
- result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[1]);
+ result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[1]);
if (result != D3D_OK)
return false;
(*d3dintf->texture.get_surface_level)(texture[1], 0, &target[1]);
- result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[2]);
+ result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[2]);
if (result != D3D_OK)
return false;
(*d3dintf->texture.get_surface_level)(texture[2], 0, &target[2]);
- result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[3]);
- if (result != D3D_OK)
- return false;
- (*d3dintf->texture.get_surface_level)(texture[3], 0, &target[3]);
+ if (!bloom)
+ {
+ result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[3]);
+ if (result != D3D_OK)
+ return false;
+ (*d3dintf->texture.get_surface_level)(texture[3], 0, &target[3]);
- result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[4]);
- if (result != D3D_OK)
- return false;
- (*d3dintf->texture.get_surface_level)(texture[4], 0, &target[4]);
+ result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[4]);
+ if (result != D3D_OK)
+ return false;
+ (*d3dintf->texture.get_surface_level)(texture[4], 0, &target[4]);
- result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture);
- if (result != D3D_OK)
- return false;
- (*d3dintf->texture.get_surface_level)(smalltexture, 0, &smalltarget);
+ result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture);
+ if (result != D3D_OK)
+ return false;
+ (*d3dintf->texture.get_surface_level)(smalltexture, 0, &smalltarget);
- result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture);
- if (result != D3D_OK)
- return false;
- (*d3dintf->texture.get_surface_level)(prescaletexture, 0, &prescaletarget);
+ result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture);
+ if (result != D3D_OK)
+ return false;
+ (*d3dintf->texture.get_surface_level)(prescaletexture, 0, &prescaletarget);
+
+ for (int index = 0; index < 11; index++)
+ {
+ bloom_texture[index] = NULL;
+ bloom_target[index] = NULL;
+ }
+ }
+ else
+ {
+ int bloom_size = (width < height) ? width : height;
+ int bloom_index = 0;
+ int bloom_width = width;
+ int bloom_height = height;
+ for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
+ {
+ bloom_width >>= 1;
+ bloom_height >>= 1;
+ result = (*d3dintf->device.create_texture)(d3d->device, bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
+ if (result != D3D_OK)
+ return false;
+ (*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
+ bloom_index++;
+ }
+ }
target_width = width * prescale_x;
target_height = height * prescale_y;
diff --git a/src/osd/windows/drawd3d.h b/src/osd/windows/drawd3d.h
index 0d1adff5f57..7cca9fee099 100644
--- a/src/osd/windows/drawd3d.h
+++ b/src/osd/windows/drawd3d.h
@@ -67,11 +67,14 @@ public:
d3d_cache_target() { }
~d3d_cache_target();
- bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y);
+ bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom);
d3d_surface *last_target;
d3d_texture *last_texture;
+ int target_width;
+ int target_height;
+
int width;
int height;
@@ -79,6 +82,9 @@ public:
d3d_cache_target *next;
d3d_cache_target *prev;
+
+ d3d_surface *bloom_target[11];
+ d3d_texture *bloom_texture[11];
};
/* d3d_render_target is the information about a Direct3D render target chain */
@@ -89,7 +95,7 @@ public:
d3d_render_target() { }
~d3d_render_target();
- bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y);
+ bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom = false);
int target_width;
int target_height;
@@ -109,6 +115,9 @@ public:
d3d_render_target *next;
d3d_render_target *prev;
+
+ d3d_surface *bloom_target[11];
+ d3d_texture *bloom_texture[11];
};
/* d3d_info is the information about Direct3D for the current screen */
diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c
index 1d84d659c77..58e0232ca07 100644
--- a/src/osd/windows/winmain.c
+++ b/src/osd/windows/winmain.c
@@ -375,6 +375,7 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_FLOOR";fs_floor", "0.0,0.0,0.0",OPTION_STRING, "signal floor level" },
{ WINOPTION_PHOSPHOR";fs_phosphor", "0.0,0.0,0.0",OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
/* NTSC simulation below this line */
+ { NULL, NULL, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" },
{ WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enable YIQ-space HLSL post-processing" },
{ WINOPTION_YIQ_CCVALUE";yiqcc", "3.59754545",OPTION_FLOAT, "Color Carrier frequency for NTSC signal processing" },
{ WINOPTION_YIQ_AVALUE";yiqa", "0.5", OPTION_FLOAT, "A value for NTSC signal processing" },
@@ -387,6 +388,14 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_YIQ_QVALUE";yiqq", "0.6", OPTION_FLOAT, "Q filter cutoff frequency for NTSC signal processing" },
{ WINOPTION_YIQ_SCAN_TIME";yiqsc", "52.6", OPTION_FLOAT, "Horizontal scanline duration for NTSC signal processing (in usec)" },
{ WINOPTION_YIQ_PHASE_COUNT";yiqp", "2", OPTION_INTEGER, "Phase Count value for NTSC signal processing" },
+ { WINOPTION_YIQ_SCAN_TIME";yiqsc", "52.6", OPTION_FLOAT, "Horizontal scanline duration for NTSC signal processing (in usec)" },
+ { WINOPTION_YIQ_PHASE_COUNT";yiqp", "2", OPTION_INTEGER, "Phase Count value for NTSC signal processing" },
+ /* Vector simulation below this line */
+ { NULL, NULL, OPTION_HEADER, "VECTOR POST-PROCESSING OPTIONS" },
+ { WINOPTION_VECTOR_TIME_SCALE";vectime", "0.0", OPTION_FLOAT, "How much the fade rate affects vector fade" },
+ { WINOPTION_VECTOR_TIME_PERIOD";vecperiod", "0.1", OPTION_FLOAT, "Vector fade rate versus screen refresh rate" },
+ { WINOPTION_VECTOR_LENGTH_SCALE";veclength", "0.9", OPTION_FLOAT, "How much length affects vector fade" },
+ { WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "4.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
// per-window options
{ NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" },
diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h
index a935d8c9c6a..167ca9ec476 100644
--- a/src/osd/windows/winmain.h
+++ b/src/osd/windows/winmain.h
@@ -1,4 +1,4 @@
-//============================================================
+ //============================================================
//
// winmain.h - Win32 main program and core headers
//
@@ -130,6 +130,10 @@
#define WINOPTION_YIQ_QVALUE "yiq_q"
#define WINOPTION_YIQ_SCAN_TIME "yiq_scan_time"
#define WINOPTION_YIQ_PHASE_COUNT "yiq_phase_count"
+#define WINOPTION_VECTOR_TIME_SCALE "vector_time_scale"
+#define WINOPTION_VECTOR_TIME_PERIOD "vector_time_period"
+#define WINOPTION_VECTOR_LENGTH_SCALE "vector_length_scale"
+#define WINOPTION_VECTOR_LENGTH_RATIO "vector_length_ratio"
// per-window options
#define WINOPTION_SCREEN "screen"
@@ -239,6 +243,10 @@ public:
float screen_yiq_q() const { return float_value(WINOPTION_YIQ_QVALUE); }
float screen_yiq_scan_time() const { return float_value(WINOPTION_YIQ_SCAN_TIME); }
int screen_yiq_phase_count() const { return int_value(WINOPTION_YIQ_PHASE_COUNT); }
+ float screen_vector_time_scale() const { return float_value(WINOPTION_VECTOR_TIME_SCALE); }
+ float screen_vector_time_period() const { return float_value(WINOPTION_VECTOR_TIME_PERIOD); }
+ float screen_vector_length_scale() const { return float_value(WINOPTION_VECTOR_LENGTH_SCALE); }
+ float screen_vector_length_ratio() const { return float_value(WINOPTION_VECTOR_LENGTH_RATIO); }
const char *screen_offset() const { return value(WINOPTION_OFFSET); }
const char *screen_scale() const { return value(WINOPTION_SCALE); }
const char *screen_power() const { return value(WINOPTION_POWER); }