summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-20 07:37:34 +0000
committer Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-20 07:37:34 +0000
commitfd7a110eba491ceaae928908d9c19b326701e314 (patch)
tree8d61c2d39985517de10825aa821a1f294f11c26e /src
parent3126517ab3fead63e505918adbdb7323c0ed5fac (diff)
HLSL Updates [Ryan Holtz, Bat Country Entertainment]
- Re-worked render target handling to align pixels better, reducing unintentional blurring - Made major fixes to CVBS simulation, significantly increasing color saturation
Diffstat (limited to 'src')
-rw-r--r--src/osd/windows/drawd3d.c90
-rw-r--r--src/osd/windows/winmain.c2
-rw-r--r--src/osd/windows/winmain.h4
3 files changed, 82 insertions, 14 deletions
diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c
index 192b1baa6a3..520d4baba87 100644
--- a/src/osd/windows/drawd3d.c
+++ b/src/osd/windows/drawd3d.c
@@ -87,7 +87,7 @@ extern void mtlog_add(const char *event);
#define ENABLE_BORDER_PIX (1)
#define VERTEX_BASE_FORMAT (D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEX2)
-#define VERTEX_BUFFER_SIZE (2048*4)
+#define VERTEX_BUFFER_SIZE (2048*6+6)
enum
{
@@ -200,6 +200,7 @@ struct _d3d_info
d3d_effect * color_effect; // pointer to the current color-effect object
d3d_effect * yiq_encode_effect; // pointer to the current YIQ encoder effect object
d3d_effect * yiq_decode_effect; // pointer to the current YIQ decoder effect object
+ d3d_vertex * fsfx_vertices; // pointer to our full-screen-quad object
poly_info poly[VERTEX_BUFFER_SIZE / 3];// array to hold polygons as they are created
int numpolys; // number of accumulated polygons
@@ -524,6 +525,7 @@ static int update_window_size(win_window_info *window);
// drawing
static void draw_line(d3d_info *d3d, const render_primitive *prim);
static void draw_quad(d3d_info *d3d, const render_primitive *prim);
+static void init_fsfx_quad(d3d_info *d3d);
// primitives
static d3d_vertex *primitive_alloc(d3d_info *d3d, int numverts);
@@ -744,6 +746,11 @@ mtlog_add("drawd3d_window_draw: begin_scene");
d3d->lockedbuf = NULL;
// loop over primitives
+ if(d3d->hlsl_enable && d3dintf->post_fx_available)
+ {
+ init_fsfx_quad(d3d);
+ }
+
mtlog_add("drawd3d_window_draw: primitive loop begin");
for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
switch (prim->type)
@@ -1974,6 +1981,59 @@ static void draw_quad(d3d_info *d3d, const render_primitive *prim)
//============================================================
+// init_fsfx_quad
+//============================================================
+
+static void init_fsfx_quad(d3d_info *d3d)
+{
+ // get a pointer to the vertex buffer
+ d3d->fsfx_vertices = primitive_alloc(d3d, 6);
+ if (d3d->fsfx_vertices == NULL)
+ return;
+
+ // fill in the vertexes clockwise
+ windows_options &options = downcast<windows_options &>(d3d->window->machine().options());
+ float scale_top = options.screen_scale_top();
+ float scale_bottom = options.screen_scale_bottom();
+
+ d3d->fsfx_vertices[0].x = (d3d->width * (scale_top * 0.5f - 0.5f));
+ d3d->fsfx_vertices[0].y = 0.0f;
+ d3d->fsfx_vertices[1].x = d3d->width - (d3d->width * (scale_top * 0.5f - 0.5f));
+ d3d->fsfx_vertices[1].y = 0.0f;
+ d3d->fsfx_vertices[2].x = (d3d->width * (scale_bottom * 0.5f - 0.5f));
+ d3d->fsfx_vertices[2].y = d3d->height;
+ d3d->fsfx_vertices[3].x = d3d->width - (d3d->width * (scale_top * 0.5f - 0.5f));
+ d3d->fsfx_vertices[3].y = 0.0f;
+ d3d->fsfx_vertices[4].x = (d3d->width * (scale_bottom * 0.5f - 0.5f));
+ d3d->fsfx_vertices[4].y = d3d->height;
+ d3d->fsfx_vertices[5].x = d3d->width - (d3d->width * (scale_bottom * 0.5f - 0.5f));
+ d3d->fsfx_vertices[5].y = d3d->height;
+
+ d3d->fsfx_vertices[0].u0 = 0.0f;
+ d3d->fsfx_vertices[0].v0 = 0.0f;
+ d3d->fsfx_vertices[1].u0 = 1.0f;
+ d3d->fsfx_vertices[1].v0 = 0.0f;
+ d3d->fsfx_vertices[2].u0 = 0.0f;
+ d3d->fsfx_vertices[2].v0 = 1.0f;
+ d3d->fsfx_vertices[3].u0 = 1.0f;
+ d3d->fsfx_vertices[3].v0 = 0.0f;
+ d3d->fsfx_vertices[4].u0 = 0.0f;
+ d3d->fsfx_vertices[4].v0 = 1.0f;
+ d3d->fsfx_vertices[5].u0 = 1.0f;
+ d3d->fsfx_vertices[5].v0 = 1.0f;
+
+ // set the color, Z parameters to standard values
+ for (int i = 0; i < 6; i++)
+ {
+ d3d->fsfx_vertices[i].z = 0.0f;
+ d3d->fsfx_vertices[i].rhw = 1.0f;
+ d3d->fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
+ }
+}
+
+
+
+//============================================================
// primitive_alloc
//============================================================
@@ -2050,13 +2110,18 @@ static void primitive_flush_pending(d3d_info *d3d)
{
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);
+ vertnum = 6;
+ }
+ else
+ {
+ vertnum = 0;
}
windows_options &options = downcast<windows_options &>(d3d->window->machine().options());
int cur_render_screen = 0;
// now do the polys
- for (polynum = vertnum = 0; polynum < d3d->numpolys; polynum++)
+ for (polynum = 0; polynum < d3d->numpolys; polynum++)
{
poly_info *poly = &d3d->poly[polynum];
int newfilter;
@@ -2160,7 +2225,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2177,8 +2242,6 @@ static void primitive_flush_pending(d3d_info *d3d)
(*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, "TargetWidth", (float)d3d->width);
- (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
(*d3dintf->effect.set_float)(curr_effect, "WValue", options.screen_yiq_w());
(*d3dintf->effect.set_float)(curr_effect, "AValue", options.screen_yiq_a());
(*d3dintf->effect.set_float)(curr_effect, "BValue", (float)poly->texture->cur_frame * options.screen_yiq_b());
@@ -2195,7 +2258,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2252,7 +2315,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2293,7 +2356,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2331,7 +2394,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2361,7 +2424,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2396,7 +2459,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2422,7 +2485,7 @@ static void primitive_flush_pending(d3d_info *d3d)
{
(*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, poly->type, 0, 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);
}
@@ -2432,7 +2495,7 @@ static void primitive_flush_pending(d3d_info *d3d)
/* Scanlines and shadow mask */
curr_effect = d3d->post_effect;
- (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture0);
+ (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture3);
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 5\n", (int)result);
@@ -2686,7 +2749,6 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour
goto error;
(*d3dintf->texture.get_surface_level)(texture->d3dtexture3, 0, &texture->d3dtarget3);
- printf("Boo\n");
result = (*d3dintf->device.create_texture)(d3d->device, (int)(scwidth * d3d->oversample_x), (int)(scheight * d3d->oversample_y), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture->d3dtexture4);
if (result != D3D_OK)
goto error;
diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c
index 71f46c8b3cd..3e98b91e1ac 100644
--- a/src/osd/windows/winmain.c
+++ b/src/osd/windows/winmain.c
@@ -341,6 +341,8 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_OVERSAMPLE_X";fs_overx(0.1-9.0)", "1.0", OPTION_FLOAT, "oversample amount in screen-relative X direction, multiple" },
{ WINOPTION_OVERSAMPLE_Y";fs_overy(0.1-9.0)", "1.0", OPTION_FLOAT, "oversample amount in screen-relative Y direction, multiple" },
{ WINOPTION_CURVATURE";fs_curv(0.0-4.0)", "0.0", OPTION_FLOAT, "screen curvature amount" },
+ { WINOPTION_SCREEN_SCALE_TOP";fs_scalex(0.0-2.0)", "1.0", OPTION_FLOAT, "screen scale, top" },
+ { WINOPTION_SCREEN_SCALE_BOTTOM";fs_scaley(0.0-2.0)", "1.0", OPTION_FLOAT, "screen scale, bottom" },
/* Beam-related values below this line*/
{ WINOPTION_PINCUSHION";fs_pin(0.0-4.0)", "0.0", OPTION_FLOAT, "pincushion amount" },
{ WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for scanlines" },
diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h
index a255ce86772..c9e1e438966 100644
--- a/src/osd/windows/winmain.h
+++ b/src/osd/windows/winmain.h
@@ -90,6 +90,8 @@
#define WINOPTION_SHADOW_MASK_USIZE "shadow_mask_usize"
#define WINOPTION_SHADOW_MASK_VSIZE "shadow_mask_vsize"
#define WINOPTION_PINCUSHION "pincushion"
+#define WINOPTION_SCREEN_SCALE_TOP "screen_scale_top"
+#define WINOPTION_SCREEN_SCALE_BOTTOM "screen_scale_bottom"
#define WINOPTION_CURVATURE "curvature"
#define WINOPTION_OVERSAMPLE_X "oversample_x"
#define WINOPTION_OVERSAMPLE_Y "oversample_y"
@@ -224,6 +226,8 @@ public:
float screen_scanline_bright_offset() const { return float_value(WINOPTION_SCANLINE_BRIGHT_OFFSET); }
float screen_scanline_offset() const { return float_value(WINOPTION_SCANLINE_OFFSET); }
float screen_pincushion() const { return float_value(WINOPTION_PINCUSHION); }
+ float screen_scale_top() const { return float_value(WINOPTION_SCREEN_SCALE_TOP); }
+ float screen_scale_bottom() const { return float_value(WINOPTION_SCREEN_SCALE_BOTTOM); }
float screen_curvature() const { return float_value(WINOPTION_CURVATURE); }
float screen_defocus_x() const { return float_value(WINOPTION_DEFOCUS_X); }
float screen_defocus_y() const { return float_value(WINOPTION_DEFOCUS_Y); }