"put HLSL back ..." fix build etc.

This commit is contained in:
David Haywood 2013-06-06 02:43:23 +00:00
parent cbf1480545
commit 4bd5fe4c21
15 changed files with 4363 additions and 29 deletions

2
.gitattributes vendored
View File

@ -8388,6 +8388,8 @@ src/osd/sdl/window.c svneol=native#text/plain
src/osd/sdl/window.h svneol=native#text/plain src/osd/sdl/window.h svneol=native#text/plain
src/osd/windows/d3d9intf.c svneol=native#text/plain src/osd/windows/d3d9intf.c svneol=native#text/plain
src/osd/windows/d3dcomm.h svneol=native#text/plain src/osd/windows/d3dcomm.h svneol=native#text/plain
src/osd/windows/d3dhlsl.c svneol=native#text/plain
src/osd/windows/d3dhlsl.h svneol=native#text/plain
src/osd/windows/d3dintf.h svneol=native#text/plain src/osd/windows/d3dintf.h svneol=native#text/plain
src/osd/windows/debugwin.c svneol=native#text/plain src/osd/windows/debugwin.c svneol=native#text/plain
src/osd/windows/debugwin.h svneol=native#text/plain src/osd/windows/debugwin.h svneol=native#text/plain

View File

@ -102,12 +102,13 @@ INLINE void convert_present_params(const present_parameters *params, D3DPRESENT_
// drawd3d9_init // drawd3d9_init
//============================================================ //============================================================
base *drawd3d9_init() base *drawd3d9_init(void)
{ {
direct3dcreate9_ptr direct3dcreate9; direct3dcreate9_ptr direct3dcreate9;
HINSTANCE dllhandle; HINSTANCE dllhandle;
IDirect3D9 *d3d9; IDirect3D9 *d3d9;
base *d3dptr; base *d3dptr;
bool post_available = true;
// dynamically grab the create function from d3d9.dll // dynamically grab the create function from d3d9.dll
dllhandle = LoadLibrary(TEXT("d3d9.dll")); dllhandle = LoadLibrary(TEXT("d3d9.dll"));
@ -138,13 +139,39 @@ base *drawd3d9_init()
} }
// dynamically grab the shader load function from d3dx9.dll // dynamically grab the shader load function from d3dx9.dll
HINSTANCE fxhandle = LoadLibrary(TEXT("d3dx9_43.dll"));
if (fxhandle == NULL)
{
post_available = false;
mame_printf_verbose("Direct3D: Warning - Unable to access d3dx9_43.dll; disabling post-effect rendering\n");
}
// import the create function
if(post_available)
{
g_load_effect = (direct3dx9_loadeffect_ptr)GetProcAddress(fxhandle, "D3DXCreateEffectFromFileW");
if (g_load_effect == NULL)
{
printf("Direct3D: Unable to find D3DXCreateEffectFromFileW\n");
FreeLibrary(dllhandle);
fxhandle = NULL;
dllhandle = NULL;
return NULL;
}
}
else
{
g_load_effect = NULL; g_load_effect = NULL;
post_available = false;
mame_printf_verbose("Direct3D: Warning - Unable to get a handle to D3DXCreateEffectFromFileW; disabling post-effect rendering\n");
}
// allocate an object to hold our data // allocate an object to hold our data
d3dptr = global_alloc(base); d3dptr = global_alloc(base);
d3dptr->version = 9; d3dptr->version = 9;
d3dptr->d3dobj = d3d9; d3dptr->d3dobj = d3d9;
d3dptr->dllhandle = dllhandle; d3dptr->dllhandle = dllhandle;
d3dptr->post_fx_available = post_available;
set_interfaces(d3dptr); set_interfaces(d3dptr);
mame_printf_verbose("Direct3D: Using Direct3D 9\n"); mame_printf_verbose("Direct3D: Using Direct3D 9\n");

3544
src/osd/windows/d3dhlsl.c Normal file

File diff suppressed because it is too large Load Diff

291
src/osd/windows/d3dhlsl.h Normal file
View File

@ -0,0 +1,291 @@
//============================================================
//
// drawd3d.c - Win32 Direct3D HLSL-specific header
//
//============================================================
//
// Copyright Aaron Giles
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the
// following conditions are met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the
// following disclaimer.
// * Redistributions in binary form must reproduce the
// above copyright notice, this list of conditions and
// the following disclaimer in the documentation and/or
// other materials provided with the distribution.
// * Neither the name 'MAME' nor the names of its
// contributors may be used to endorse or promote
// products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGE (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//============================================================
#ifndef __WIN_D3DHLSL__
#define __WIN_D3DHLSL__
#include "aviio.h"
//============================================================
// CONSTANTS
//============================================================
#define HLSL_VECTOR (1)
#define CRT_BLOOM (1)
//============================================================
// TYPE DEFINITIONS
//============================================================
namespace d3d
{
class render_target;
class cache_target;
class renderer;
/* hlsl_options is the information about runtime-mutable Direct3D HLSL options */
/* in the future this will be moved into an OSD/emu shared buffer */
struct hlsl_options
{
bool params_dirty;
float shadow_mask_alpha;
char shadow_mask_texture[1024];
int shadow_mask_count_x;
int shadow_mask_count_y;
float shadow_mask_u_size;
float shadow_mask_v_size;
float curvature;
float pincushion;
float scanline_alpha;
float scanline_scale;
float scanline_height;
float scanline_bright_scale;
float scanline_bright_offset;
float scanline_offset;
float defocus[4];
float converge_x[3];
float converge_y[3];
float radial_converge_x[3];
float radial_converge_y[3];
float red_ratio[3];
float grn_ratio[3];
float blu_ratio[3];
float offset[3];
float scale[3];
float power[3];
float floor[3];
float phosphor[3];
float saturation;
// NTSC
bool yiq_enable;
float yiq_cc;
float yiq_a;
float yiq_b;
float yiq_o;
float yiq_p;
float yiq_n;
float yiq_y;
float yiq_i;
float yiq_q;
float yiq_scan_time;
int yiq_phase_count;
// Vectors
float vector_length_scale;
float vector_length_ratio;
// Bloom
float vector_bloom_scale;
float raster_bloom_scale;
float bloom_level0_weight;
float bloom_level1_weight;
float bloom_level2_weight;
float bloom_level3_weight;
float bloom_level4_weight;
float bloom_level5_weight;
float bloom_level6_weight;
float bloom_level7_weight;
float bloom_level8_weight;
float bloom_level9_weight;
float bloom_level10_weight;
};
class shaders
{
public:
// construction/destruction
shaders();
~shaders();
void init(base *d3dintf, win_window_info *window);
bool enabled() { return master_enable; }
void toggle();
bool vector_enabled() { return master_enable && vector_enable && (bool)HLSL_VECTOR; }
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 init_effect_info(poly_info *poly);
void render_quad(poly_info *poly, int vertnum);
bool register_texture(texture_info *texture);
bool register_prescaled_texture(texture_info *texture);
bool add_render_target(renderer* d3d, texture_info* info, int width, int height, int xprescale, int yprescale);
bool add_cache_target(renderer* d3d, texture_info* info, int width, int height, int xprescale, int yprescale, int screen_index);
void window_save();
void window_record();
bool recording() { return avi_output_file != NULL; }
void avi_update_snap(surface *surface);
void render_snapshot(surface *surface);
void record_texture();
void init_fsfx_quad(void *vertbuf);
void set_texture(texture_info *texture);
render_target * find_render_target(texture_info *info);
void remove_render_target(texture_info *texture);
void remove_render_target(int width, int height, UINT32 screen_index, UINT32 page_index);
void remove_render_target(render_target *rt);
int create_resources(bool reset);
void delete_resources(bool reset);
// slider-related functions
slider_state *init_slider_list();
struct slider_desc
{
const char * name;
int minval;
int defval;
int maxval;
int step;
INT32 (*adjustor)(running_machine &, void *, astring *, INT32);
};
private:
void blit(surface *dst, texture *src, surface *new_dst,
D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count,
int dstw, int dsth);
void blit(surface *dst, texture *src, surface *new_dst,
D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count);
void enumerate_screens();
void end_avi_recording();
void begin_avi_recording(const char *name);
bool register_texture(texture_info *texture, int width, int height, int xscale, int yscale);
render_target* find_render_target(int width, int height, UINT32 screen_index, UINT32 page_index);
cache_target * find_cache_target(UINT32 screen_index, int width, int height);
void remove_cache_target(cache_target *cache);
base * d3dintf; // D3D interface
win_window_info * window; // D3D window info
bool master_enable; // overall enable flag
bool vector_enable; // vector post-processing enable flag
bool paused; // whether or not rendering is currently paused
int num_screens; // number of emulated physical screens
int curr_screen; // current screen for render target operations
int curr_frame; // current frame (0/1) of a screen for render target operations
int lastidx; // index of the last-encountered target
bool write_ini; // enable external ini saving
bool read_ini; // enable external ini loading
int prescale_force_x; // prescale force x
int prescale_force_y; // prescale force y
int prescale_size_x; // prescale size x
int prescale_size_y; // prescale size y
int preset; // preset, if relevant
bitmap_argb32 shadow_bitmap; // shadow mask bitmap for post-processing shader
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
int avi_frame; // AVI frame
attotime avi_frame_period; // AVI frame period
attotime avi_next_frame_time; // AVI next frame time
surface * avi_copy_surface; // AVI destination surface in system memory
texture * avi_copy_texture; // AVI destination texture in system memory
surface * avi_final_target; // AVI upscaled surface
texture * avi_final_texture; // AVI upscaled texture
surface * black_surface; // black dummy surface
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
surface * snap_copy_target; // snapshot destination surface in system memory
texture * snap_copy_texture; // snapshot destination surface in system memory
surface * snap_target; // snapshot upscaled surface
texture * snap_texture; // snapshot upscaled texture
int snap_width; // snapshot width
int snap_height; // snapshot height
bool lines_pending; // whether or not we have lines to flush on the next quad
bool initialized; // whether or not we're initialize
// HLSL effects
surface * backbuffer; // pointer to our device's backbuffer
effect * curr_effect; // pointer to the currently active effect object
effect * default_effect; // pointer to the primary-effect object
effect * prescale_effect; // pointer to the prescale-effect object
effect * post_effect; // pointer to the post-effect object
effect * pincushion_effect; // pointer to the pincushion-effect object
effect * focus_effect; // pointer to the focus-effect object
effect * phosphor_effect; // pointer to the phosphor-effect object
effect * deconverge_effect; // pointer to the deconvergence-effect object
effect * color_effect; // pointer to the color-effect object
effect * yiq_encode_effect; // pointer to the YIQ encoder effect object
effect * yiq_decode_effect; // pointer to the YIQ decoder effect object
#if (HLSL_VECTOR || CRT_BLOOM)
effect * bloom_effect; // pointer to the bloom composite effect
effect * downsample_effect; // pointer to the bloom downsample effect
#endif
#if (HLSL_VECTOR)
effect * vector_effect; // pointer to the vector-effect object
#endif
vertex * fsfx_vertices; // pointer to our full-screen-quad object
public:
render_target * targethead;
cache_target * cachehead;
static slider_desc s_sliders[];
static hlsl_options s_hlsl_presets[4];
};
};
#endif

View File

@ -42,7 +42,6 @@
#ifndef __WIN_D3DINTF__ #ifndef __WIN_D3DINTF__
#define __WIN_D3DINTF__ #define __WIN_D3DINTF__
//#include "winmain.h"
//============================================================ //============================================================
// CONSTANTS // CONSTANTS
@ -267,6 +266,7 @@ struct base
int version; int version;
void * d3dobj; void * d3dobj;
HINSTANCE dllhandle; HINSTANCE dllhandle;
bool post_fx_available;
// interface pointers // interface pointers
interface d3d; interface d3d;
@ -282,7 +282,7 @@ struct base
// PROTOTYPES // PROTOTYPES
//============================================================ //============================================================
base *drawd3d9_init(); base *drawd3d9_init(void);
}; };

View File

@ -217,6 +217,7 @@ static void drawd3d_window_destroy(win_window_info *window);
static render_primitive_list *drawd3d_window_get_primitives(win_window_info *window); static render_primitive_list *drawd3d_window_get_primitives(win_window_info *window);
static void drawd3d_window_save(win_window_info *window); static void drawd3d_window_save(win_window_info *window);
static void drawd3d_window_record(win_window_info *window); static void drawd3d_window_record(win_window_info *window);
static void drawd3d_window_toggle_fsfx(win_window_info *window);
static int drawd3d_window_draw(win_window_info *window, HDC dc, int update); static int drawd3d_window_draw(win_window_info *window, HDC dc, int update);
@ -250,12 +251,22 @@ static void drawd3d_exit(void)
(*d3dintf->d3d.release)(d3dintf); (*d3dintf->d3d.release)(d3dintf);
} }
static void drawd3d_window_toggle_fsfx(win_window_info *window)
{
d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
d3d->set_restarting(true);
}
static void drawd3d_window_record(win_window_info *window) static void drawd3d_window_record(win_window_info *window)
{ {
d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
d3d->get_shaders()->window_record();
} }
static void drawd3d_window_save(win_window_info *window) static void drawd3d_window_save(win_window_info *window)
{ {
d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
d3d->get_shaders()->window_save();
} }
@ -272,6 +283,9 @@ static void drawd3d_window_destroy(win_window_info *window)
if (d3d == NULL) if (d3d == NULL)
return; return;
if (d3d->get_shaders()->recording())
d3d->get_shaders()->window_record();
// free the memory in the window // free the memory in the window
global_free(d3d); global_free(d3d);
window->drawdata = NULL; window->drawdata = NULL;
@ -318,6 +332,7 @@ int drawd3d_init(running_machine &machine, win_draw_callbacks *callbacks)
callbacks->window_draw = drawd3d_window_draw; callbacks->window_draw = drawd3d_window_draw;
callbacks->window_save = drawd3d_window_save; callbacks->window_save = drawd3d_window_save;
callbacks->window_record = drawd3d_window_record; callbacks->window_record = drawd3d_window_record;
callbacks->window_toggle_fsfx = drawd3d_window_toggle_fsfx;
callbacks->window_destroy = drawd3d_window_destroy; callbacks->window_destroy = drawd3d_window_destroy;
return 0; return 0;
} }
@ -354,6 +369,7 @@ void renderer::set_texture(texture_info *texture)
m_last_texture = texture; m_last_texture = texture;
m_last_texture_flags = (texture == NULL ? 0 : texture->get_flags()); m_last_texture_flags = (texture == NULL ? 0 : texture->get_flags());
HRESULT result = (*d3dintf->device.set_texture)(m_device, 0, (texture == NULL) ? get_default_texture()->get_finaltex() : texture->get_finaltex()); HRESULT result = (*d3dintf->device.set_texture)(m_device, 0, (texture == NULL) ? get_default_texture()->get_finaltex() : texture->get_finaltex());
m_shaders->set_texture(texture);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture call\n", (int)result); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture call\n", (int)result);
} }
} }
@ -614,10 +630,114 @@ texture_info *texture_manager::find_texinfo(const render_texinfo *texinfo, UINT3
texture->get_texinfo().width == texinfo->width && texture->get_texinfo().width == texinfo->width &&
texture->get_texinfo().height == texinfo->height && texture->get_texinfo().height == texinfo->height &&
((texture->get_flags() ^ flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0) ((texture->get_flags() ^ flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0)
{
// Reject a texture if it belongs to an out-of-date render target, so as to cause the HLSL system to re-cache
if (m_renderer->get_shaders()->enabled() && texinfo->width != 0 && texinfo->height != 0 && (flags & PRIMFLAG_SCREENTEX_MASK) != 0)
{
if (m_renderer->get_shaders()->find_render_target(texture) != NULL)
{ {
return texture; return texture;
} }
} }
else
{
return texture;
}
}
}
// Nothing found
/*int checkidx = 0;
for (texture = m_renderer->get_texture_manager()->get_texlist(); texture != NULL; texture = texture->get_next())
{
printf("Checking texture index %d\n", checkidx);
UINT32 test_screen = (UINT32)texture->get_texinfo().osddata >> 1;
UINT32 test_page = (UINT32)texture->get_texinfo().osddata & 1;
UINT32 prim_screen = (UINT32)texinfo->osddata >> 1;
UINT32 prim_page = (UINT32)texinfo->osddata & 1;
if (test_screen != prim_screen || test_page != prim_page)
{
printf("No screen/page match: %d vs. %d, %d vs. %d\n", test_screen, prim_screen, test_page, prim_page);
continue;
}
if (texture->get_hash() == hash &&
texture->get_texinfo().base == texinfo->base &&
texture->get_texinfo().width == texinfo->width &&
texture->get_texinfo().height == texinfo->height &&
((texture->get_flags() ^ flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0)
{
// Reject a texture if it belongs to an out-of-date render target, so as to cause the HLSL system to re-cache
if (m_renderer->get_shaders()->enabled() && texinfo->width != 0 && texinfo->height != 0 && (flags & PRIMFLAG_SCREENTEX_MASK) != 0)
{
if (m_renderer->get_shaders()->find_render_target(texture) != NULL)
{
return texture;
}
}
else
{
return texture;
}
}
if (texture->get_hash() != hash)
{
printf("No hash match: %d vs. %d\n", texture->get_hash(), hash);
}
if (texture->get_texinfo().base != texinfo->base)
{
printf("No base match\n");
}
if (texture->get_texinfo().width != texinfo->width)
{
printf("No width match: %d vs. %d\n", texture->get_texinfo().width, texinfo->width);
}
if (texture->get_texinfo().height != texinfo->height)
{
printf("No height match: %d vs. %d\n", texture->get_texinfo().height, texinfo->height);
}
if (((texture->get_flags() ^ flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) != 0)
{
printf("No flag match: %08x & %08x = %08x\n", texture->get_flags(), flags, ((texture->get_flags() ^ flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)));
}
printf("\n");
checkidx++;
}
printf("\n\n\n\n");*/
// Nothing found, check if we need to unregister something with HLSL
if (m_renderer->get_shaders()->enabled())
{
if (texinfo->width == 0 || texinfo->height == 0)
{
return NULL;
}
UINT32 prim_screen = texinfo->osddata >> 1;
UINT32 prim_page = texinfo->osddata & 1;
for (texture = m_renderer->get_texture_manager()->get_texlist(); texture != NULL; texture = texture->get_next())
{
UINT32 test_screen = texture->get_texinfo().osddata >> 1;
UINT32 test_page = texture->get_texinfo().osddata & 1;
if (test_screen != prim_screen || test_page != prim_page)
{
continue;
}
// Clear out our old texture reference
if (texture->get_hash() == hash &&
texture->get_texinfo().base == texinfo->base &&
((texture->get_flags() ^ flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0 &&
(texture->get_texinfo().width != texinfo->width ||
texture->get_texinfo().height != texinfo->height))
{
m_renderer->get_shaders()->remove_render_target(texture);
}
}
}
return NULL; return NULL;
} }
@ -627,12 +747,14 @@ renderer::renderer(win_window_info *window)
m_device = NULL; m_device = NULL;
m_restarting = false; m_restarting = false;
m_window = window; m_window = window;
m_shaders = NULL;
m_numverts = 0; m_numverts = 0;
m_numpolys = 0; m_numpolys = 0;
m_vertexbuf = NULL; m_vertexbuf = NULL;
m_lockedbuf = NULL; m_lockedbuf = NULL;
m_vectorbatch = NULL; m_vectorbatch = NULL;
m_last_texture = NULL; m_last_texture = NULL;
m_hlsl_buf = NULL;
m_texture_manager = NULL; m_texture_manager = NULL;
} }
@ -658,6 +780,8 @@ int renderer::pre_window_draw_check()
// if we're restarting the renderer, leave things alone // if we're restarting the renderer, leave things alone
if (m_restarting) if (m_restarting)
{ {
m_shaders->toggle();
// free all existing resources and re-create // free all existing resources and re-create
device_delete_resources(); device_delete_resources();
device_create_resources(); device_create_resources();
@ -711,6 +835,13 @@ void texture_manager::update_textures()
} }
} }
} }
else if(m_renderer->get_shaders()->vector_enabled() && PRIMFLAG_GET_VECTORBUF(prim->flags))
{
if (!m_renderer->get_shaders()->get_vector_target())
{
m_renderer->get_shaders()->create_vector_target(prim);
}
}
} }
} }
@ -719,6 +850,8 @@ void renderer::begin_frame()
HRESULT result = (*d3dintf->device.clear)(m_device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0); HRESULT result = (*d3dintf->device.clear)(m_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); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
m_shaders->begin_frame();
m_window->primlist->acquire_lock(); m_window->primlist->acquire_lock();
// first update any textures // first update any textures
@ -731,6 +864,12 @@ mtlog_add("drawd3d_window_draw: begin_scene");
m_lockedbuf = NULL; m_lockedbuf = NULL;
if(m_shaders->enabled())
{
m_hlsl_buf = (void*)mesh_alloc(6);
m_shaders->init_fsfx_quad(m_hlsl_buf);
}
m_line_count = 0; m_line_count = 0;
// loop over primitives // loop over primitives
for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next()) for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next())
@ -740,6 +879,11 @@ mtlog_add("drawd3d_window_draw: begin_scene");
void renderer::process_primitives() void renderer::process_primitives()
{ {
if (m_line_count && m_shaders->enabled() && d3dintf->post_fx_available)
{
batch_vectors();
}
// Rotating index for vector time offsets // Rotating index for vector time offsets
for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next()) for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next())
{ {
@ -764,6 +908,11 @@ void renderer::process_primitives()
throw emu_fatalerror("Unexpected render_primitive type"); throw emu_fatalerror("Unexpected render_primitive type");
} }
} }
if (m_line_count && !(m_shaders->enabled() && d3dintf->post_fx_available))
{
batch_vectors();
}
} }
void renderer::end_frame() void renderer::end_frame()
@ -773,6 +922,8 @@ void renderer::end_frame()
// flush any pending polygons // flush any pending polygons
primitive_flush_pending(); primitive_flush_pending();
m_shaders->end_frame();
// finish the scene // finish the scene
HRESULT result = (*d3dintf->device.end_scene)(m_device); HRESULT result = (*d3dintf->device.end_scene)(m_device);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device end_scene call\n", (int)result); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device end_scene call\n", (int)result);
@ -902,6 +1053,10 @@ try_again:
} }
} }
int ret = m_shaders->create_resources(false);
if (ret != 0)
return ret;
return device_create_resources(); return device_create_resources();
} }
@ -917,7 +1072,7 @@ int renderer::device_create_resources()
HRESULT result = (*d3dintf->device.create_vertex_buffer)(m_device, HRESULT result = (*d3dintf->device.create_vertex_buffer)(m_device,
sizeof(vertex) * VERTEX_BUFFER_SIZE, sizeof(vertex) * VERTEX_BUFFER_SIZE,
D3DUSAGE_DYNAMIC | D3DUSAGE_SOFTWAREPROCESSING | D3DUSAGE_WRITEONLY, D3DUSAGE_DYNAMIC | D3DUSAGE_SOFTWAREPROCESSING | D3DUSAGE_WRITEONLY,
VERTEX_BASE_FORMAT | D3DFVF_XYZRHW, VERTEX_BASE_FORMAT | ((m_shaders->enabled() && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW),
D3DPOOL_DEFAULT, &m_vertexbuf); D3DPOOL_DEFAULT, &m_vertexbuf);
if (result != D3D_OK) if (result != D3D_OK)
{ {
@ -926,7 +1081,8 @@ int renderer::device_create_resources()
} }
// set the vertex format // set the vertex format
result = (*d3dintf->device.set_vertex_format)(m_device, (D3DFORMAT)(VERTEX_BASE_FORMAT | D3DFVF_XYZRHW)); result = (*d3dintf->device.set_vertex_format)(m_device, (D3DFORMAT)(VERTEX_BASE_FORMAT | ((m_shaders->enabled() &&
d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW)));
if (result != D3D_OK) if (result != D3D_OK)
{ {
mame_printf_error("Error setting vertex format (%08X)", (UINT32)result); mame_printf_error("Error setting vertex format (%08X)", (UINT32)result);
@ -983,6 +1139,12 @@ renderer::~renderer()
void renderer::device_delete() void renderer::device_delete()
{ {
// free our effects
m_shaders->delete_resources(false);
// delete the HLSL interface
global_free(m_shaders);
// free our base resources // free our base resources
device_delete_resources(); device_delete_resources();
@ -1024,10 +1186,20 @@ int renderer::device_verify_caps()
{ {
int retval = 0; int retval = 0;
m_shaders = global_alloc_clear(shaders);
m_shaders->init(d3dintf, m_window);
DWORD tempcaps; DWORD tempcaps;
HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps);
if (result != D3D_OK) mame_printf_verbose("Direct3D Error %08X during get_caps_dword call\n", (int)result);
if(tempcaps < 512)
{
mame_printf_verbose("Direct3D: Warning - Device does not support Pixel Shader 3.0, falling back to non-PS rendering\n");
d3dintf->post_fx_available = false;
}
// verify presentation capabilities // verify presentation capabilities
HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_PRESENTATION_INTERVALS, &tempcaps); result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_PRESENTATION_INTERVALS, &tempcaps);
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during get_caps_dword call\n", (int)result); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during get_caps_dword call\n", (int)result);
if (!(tempcaps & D3DPRESENT_INTERVAL_IMMEDIATE)) if (!(tempcaps & D3DPRESENT_INTERVAL_IMMEDIATE))
{ {
@ -1094,6 +1266,7 @@ int renderer::device_test_cooperative()
// free all existing resources and call reset on the device // free all existing resources and call reset on the device
device_delete_resources(); device_delete_resources();
m_shaders->delete_resources(true);
result = (*d3dintf->device.reset)(m_device, &m_presentation); result = (*d3dintf->device.reset)(m_device, &m_presentation);
// if it didn't work, punt to GDI // if it didn't work, punt to GDI
@ -1110,6 +1283,13 @@ int renderer::device_test_cooperative()
device_delete(); device_delete();
return 1; return 1;
} }
if (m_shaders->create_resources(true))
{
mame_printf_verbose("Direct3D: failed to recreate HLSL resources for device; failing permanently\n");
device_delete();
return 1;
}
} }
return 0; return 0;
} }
@ -1364,9 +1544,9 @@ void renderer::batch_vectors()
m_vectorbatch = mesh_alloc(m_line_count * vector_size); m_vectorbatch = mesh_alloc(m_line_count * vector_size);
m_batchindex = 0; m_batchindex = 0;
//static int start_index = 0; static int start_index = 0;
//int line_index = 0; int line_index = 0;
//float period = options.screen_vector_time_period(); float period = options.screen_vector_time_period();
UINT32 cached_flags = 0; UINT32 cached_flags = 0;
for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next()) for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next())
{ {
@ -1375,14 +1555,14 @@ void renderer::batch_vectors()
case render_primitive::LINE: case render_primitive::LINE:
if (PRIMFLAG_GET_VECTOR(prim->flags)) if (PRIMFLAG_GET_VECTOR(prim->flags))
{ {
/*if (period == 0.0f || m_line_count == 0) if (period == 0.0f || m_line_count == 0)
{ {
batch_vector(prim, 1.0f); batch_vector(prim, 1.0f);
} }
else*/ else
{ {
batch_vector(prim, 1.0f);//(float)(start_index + line_index) / ((float)m_line_count * period)); batch_vector(prim, (float)(start_index + line_index) / ((float)m_line_count * period));
//line_index++; line_index++;
} }
cached_flags = prim->flags; cached_flags = prim->flags;
} }
@ -1399,11 +1579,11 @@ void renderer::batch_vectors()
m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f, 0.0f, 0.0f); m_texture_manager->get_vector_texture(), D3DTOP_MODULATE, 0.0f, 1.0f, 0.0f, 0.0f);
m_numpolys++; m_numpolys++;
//start_index += (int)((float)line_index * period); start_index += (int)((float)line_index * period);
//if (m_line_count > 0) if (m_line_count > 0)
//{ {
// start_index %= m_line_count; start_index %= m_line_count;
//} }
} }
void renderer::batch_vector(const render_primitive *prim, float line_time) void renderer::batch_vector(const render_primitive *prim, float line_time)
@ -1699,7 +1879,14 @@ vertex *renderer::mesh_alloc(int numverts)
// if we're going to overflow, flush // if we're going to overflow, flush
if (m_lockedbuf != NULL && m_numverts + numverts >= VERTEX_BUFFER_SIZE) if (m_lockedbuf != NULL && m_numverts + numverts >= VERTEX_BUFFER_SIZE)
{ {
printf("request for %d verts\n", numverts);
primitive_flush_pending(); primitive_flush_pending();
if(m_shaders->enabled())
{
m_hlsl_buf = (void*)mesh_alloc(6);
m_shaders->init_fsfx_quad(m_hlsl_buf);
}
} }
// if we don't have a lock, grab it now // if we don't have a lock, grab it now
@ -1743,7 +1930,13 @@ void renderer::primitive_flush_pending()
result = (*d3dintf->device.set_stream_source)(m_device, 0, m_vertexbuf, sizeof(vertex)); result = (*d3dintf->device.set_stream_source)(m_device, 0, m_vertexbuf, sizeof(vertex));
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_stream_source call\n", (int)result); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_stream_source call\n", (int)result);
m_shaders->begin_draw();
int vertnum = 0; int vertnum = 0;
if (m_shaders->enabled())
{
vertnum = 6;
}
// now do the polys // now do the polys
for (int polynum = 0; polynum < m_numpolys; polynum++) for (int polynum = 0; polynum < m_numpolys; polynum++)
@ -1764,6 +1957,8 @@ void renderer::primitive_flush_pending()
set_filter(newfilter); set_filter(newfilter);
set_wrap(PRIMFLAG_GET_TEXWRAP(flags) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); set_wrap(PRIMFLAG_GET_TEXWRAP(flags) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);
set_modmode(m_poly[polynum].get_modmode()); set_modmode(m_poly[polynum].get_modmode());
m_shaders->init_effect_info(&m_poly[polynum]);
} }
// set the blendmode if different // set the blendmode if different
@ -1777,14 +1972,23 @@ void renderer::primitive_flush_pending()
assert(vertnum + m_poly[polynum].get_vertcount() <= m_numverts); assert(vertnum + m_poly[polynum].get_vertcount() <= m_numverts);
if(m_shaders->enabled() && d3dintf->post_fx_available)
{
m_shaders->render_quad(&m_poly[polynum], vertnum);
}
else
{
// add the primitives // add the primitives
result = (*d3dintf->device.draw_primitive)(m_device, m_poly[polynum].get_type(), vertnum, result = (*d3dintf->device.draw_primitive)(m_device, m_poly[polynum].get_type(), vertnum,
m_poly[polynum].get_count()); m_poly[polynum].get_count());
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
}
vertnum += m_poly[polynum].get_vertcount(); vertnum += m_poly[polynum].get_vertcount();
} }
m_shaders->end_draw();
// reset the vertex count // reset the vertex count
m_numverts = 0; m_numverts = 0;
m_numpolys = 0; m_numpolys = 0;
@ -1913,6 +2117,12 @@ texture_info::texture_info(texture_manager *manager, const render_texinfo* texso
{ {
m_d3dfinaltex = m_d3dtex; m_d3dfinaltex = m_d3dtex;
m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN; m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN;
if (m_renderer->get_shaders()->enabled() && !m_renderer->get_shaders()->register_texture(this))
{
goto error;
}
break; break;
} }
} }
@ -1952,6 +2162,10 @@ texture_info::texture_info(texture_manager *manager, const render_texinfo* texso
result = (*d3dintf->device.create_texture)(m_renderer->get_device(), scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, finalfmt, D3DPOOL_DEFAULT, &m_d3dfinaltex); result = (*d3dintf->device.create_texture)(m_renderer->get_device(), scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, finalfmt, D3DPOOL_DEFAULT, &m_d3dfinaltex);
if (result == D3D_OK) if (result == D3D_OK)
{ {
if (m_renderer->get_shaders()->enabled() && !m_renderer->get_shaders()->register_prescaled_texture(this))
{
goto error;
}
break; break;
} }
(*d3dintf->texture.release)(m_d3dtex); (*d3dintf->texture.release)(m_d3dtex);
@ -1973,6 +2187,7 @@ texture_info::texture_info(texture_manager *manager, const render_texinfo* texso
return; return;
error: error:
d3dintf->post_fx_available = false;
printf("Direct3D: Critical warning: A texture failed to allocate. Expect things to get bad quickly.\n"); printf("Direct3D: Critical warning: A texture failed to allocate. Expect things to get bad quickly.\n");
if (m_d3dsurface != NULL) if (m_d3dsurface != NULL)
(*d3dintf->surface.release)(m_d3dsurface); (*d3dintf->surface.release)(m_d3dsurface);

View File

@ -43,6 +43,9 @@
#define __WIN_DRAWD3D__ #define __WIN_DRAWD3D__
#include "d3dhlsl.h"
//============================================================ //============================================================
// CONSTANTS // CONSTANTS
//============================================================ //============================================================
@ -198,6 +201,8 @@ public:
texture_info * get_default_texture() { return m_texture_manager->get_default_texture(); } texture_info * get_default_texture() { return m_texture_manager->get_default_texture(); }
texture_info * get_vector_texture() { return m_texture_manager->get_vector_texture(); } texture_info * get_vector_texture() { return m_texture_manager->get_vector_texture(); }
shaders * get_shaders() { return m_shaders; }
private: private:
int m_adapter; // ordinal adapter number int m_adapter; // ordinal adapter number
int m_width; // current width int m_width; // current width
@ -239,6 +244,9 @@ private:
D3DTEXTUREADDRESS m_last_wrap; // previous wrap state D3DTEXTUREADDRESS m_last_wrap; // previous wrap state
DWORD m_last_modmode; // previous texture modulation DWORD m_last_modmode; // previous texture modulation
void * m_hlsl_buf; // HLSL vertex data
shaders * m_shaders; // HLSL interface
texture_manager * m_texture_manager; // texture manager texture_manager * m_texture_manager; // texture manager
int m_line_count; int m_line_count;

View File

@ -223,6 +223,7 @@ int drawdd_init(running_machine &machine, win_draw_callbacks *callbacks)
callbacks->window_draw = drawdd_window_draw; callbacks->window_draw = drawdd_window_draw;
callbacks->window_save = NULL; callbacks->window_save = NULL;
callbacks->window_record = NULL; callbacks->window_record = NULL;
callbacks->window_toggle_fsfx = NULL;
callbacks->window_destroy = drawdd_window_destroy; callbacks->window_destroy = drawdd_window_destroy;
mame_printf_verbose("DirectDraw: Using DirectDraw 7\n"); mame_printf_verbose("DirectDraw: Using DirectDraw 7\n");

View File

@ -93,6 +93,7 @@ int drawgdi_init(running_machine &machine, win_draw_callbacks *callbacks)
callbacks->window_draw = drawgdi_window_draw; callbacks->window_draw = drawgdi_window_draw;
callbacks->window_save = NULL; callbacks->window_save = NULL;
callbacks->window_record = NULL; callbacks->window_record = NULL;
callbacks->window_toggle_fsfx = NULL;
callbacks->window_destroy = drawgdi_window_destroy; callbacks->window_destroy = drawgdi_window_destroy;
return 0; return 0;
} }

View File

@ -77,6 +77,7 @@ int drawnone_init(running_machine &machine, win_draw_callbacks *callbacks)
callbacks->window_draw = drawnone_window_draw; callbacks->window_draw = drawnone_window_draw;
callbacks->window_save = NULL; callbacks->window_save = NULL;
callbacks->window_record = NULL; callbacks->window_record = NULL;
callbacks->window_toggle_fsfx = NULL;
callbacks->window_destroy = drawnone_window_destroy; callbacks->window_destroy = drawnone_window_destroy;
return 0; return 0;
} }

View File

@ -776,6 +776,24 @@ void windows_osd_interface::customize_input_type_list(simple_list<input_type_ent
entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_ENTER); entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_ENTER);
break; break;
// alt-F12 for fullscreen snap
case IPT_OSD_2:
entry->configure_osd("RENDER_SNAP", "Take Rendered Snapshot");
entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_F12, input_seq::not_code, KEYCODE_LCONTROL);
break;
// alt-F11 for fullscreen video
case IPT_OSD_3:
entry->configure_osd("RENDER_AVI", "Record Rendered Video");
entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_F11);
break;
// ctrl-alt-F12 to toggle post-processing
case IPT_OSD_4:
entry->configure_osd("POST_PROCESS", "Toggle Post-Processing");
entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_LCONTROL, KEYCODE_F5);
break;
// leave everything else alone // leave everything else alone
default: default:
break; break;

View File

@ -366,6 +366,18 @@ static void check_osd_inputs(running_machine &machine)
// check for toggling fullscreen mode // check for toggling fullscreen mode
if (ui_input_pressed(machine, IPT_OSD_1)) if (ui_input_pressed(machine, IPT_OSD_1))
winwindow_toggle_full_screen(); winwindow_toggle_full_screen();
// check for taking fullscreen snap
if (ui_input_pressed(machine, IPT_OSD_2))
winwindow_take_snap();
// check for taking fullscreen video
if (ui_input_pressed(machine, IPT_OSD_3))
winwindow_take_video();
// check for taking fullscreen video
if (ui_input_pressed(machine, IPT_OSD_4))
winwindow_toggle_fsfx();
} }

View File

@ -306,6 +306,7 @@ OSDCOREOBJS = \
OSDOBJS = \ OSDOBJS = \
$(WINOBJ)/d3d9intf.o \ $(WINOBJ)/d3d9intf.o \
$(WINOBJ)/drawd3d.o \ $(WINOBJ)/drawd3d.o \
$(WINOBJ)/d3dhlsl.o \
$(WINOBJ)/drawdd.o \ $(WINOBJ)/drawdd.o \
$(WINOBJ)/drawgdi.o \ $(WINOBJ)/drawgdi.o \
$(WINOBJ)/drawnone.o \ $(WINOBJ)/drawnone.o \

View File

@ -331,6 +331,85 @@ const options_entry windows_options::s_option_entries[] =
{ NULL, NULL, OPTION_HEADER, "DIRECT3D-SPECIFIC OPTIONS" }, { NULL, NULL, OPTION_HEADER, "DIRECT3D-SPECIFIC OPTIONS" },
{ WINOPTION_FILTER ";d3dfilter;flt", "1", OPTION_BOOLEAN, "enable bilinear filtering on screen output" }, { WINOPTION_FILTER ";d3dfilter;flt", "1", OPTION_BOOLEAN, "enable bilinear filtering on screen output" },
// post-processing options
{ NULL, NULL, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" },
{ WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enable HLSL post-processing (PS3.0 required)" },
{ WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" },
{ WINOPTION_HLSL_INI_READ, "0", OPTION_BOOLEAN, "enable HLSL INI reading" },
{ WINOPTION_HLSL_INI_WRITE, "0", OPTION_BOOLEAN, "enable HLSL INI writing" },
{ WINOPTION_HLSL_INI_NAME, "%g", OPTION_STRING, "HLSL INI file name for this game" },
{ WINOPTION_HLSL_PRESCALE_X, "0", OPTION_INTEGER, "HLSL pre-scale override factor for X (0 for auto)" },
{ WINOPTION_HLSL_PRESCALE_Y, "0", OPTION_INTEGER, "HLSL pre-scale override factor for Y (0 for auto)" },
{ WINOPTION_HLSL_PRESET";(-1-3)", "-1", OPTION_INTEGER, "HLSL preset to use (0-3)" },
{ WINOPTION_HLSL_WRITE, NULL, OPTION_STRING, "enable HLSL AVI writing (huge disk bandwidth suggested)" },
{ WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" },
{ WINOPTION_HLSL_SNAP_HEIGHT, "1536", OPTION_STRING, "HLSL upscaled-snapshot height" },
{ WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" },
{ WINOPTION_SHADOW_MASK_TEXTURE";fs_shadwt(0.0-1.0)", "aperture.png", OPTION_STRING, "shadow mask texture name" },
{ WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww", "320", OPTION_INTEGER, "shadow mask width, in phosphor dots" },
{ WINOPTION_SHADOW_MASK_COUNT_Y";fs_shadwh", "240", OPTION_INTEGER, "shadow mask height, in phosphor dots" },
{ WINOPTION_SHADOW_MASK_USIZE";fs_shadwu(0.0-1.0)", "0.09375", OPTION_FLOAT, "shadow mask texture size in U direction" },
{ WINOPTION_SHADOW_MASK_VSIZE";fs_shadwv(0.0-1.0)", "0.109375", OPTION_FLOAT, "shadow mask texture size in V direction" },
{ WINOPTION_CURVATURE";fs_curv(0.0-4.0)", "0.03", OPTION_FLOAT, "screen curvature amount" },
/* Beam-related values below this line*/
{ WINOPTION_PINCUSHION";fs_pin(0.0-4.0)", "0.03", OPTION_FLOAT, "pincushion amount" },
{ WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)", "1.0", OPTION_FLOAT, "overall alpha scaling value for scanlines" },
{ WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)", "1.0", OPTION_FLOAT, "overall height scaling value for scanlines" },
{ WINOPTION_SCANLINE_HEIGHT";fs_scanh(0.0-4.0)", "1.0", OPTION_FLOAT, "individual height scaling value for scanlines" },
{ WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-2.0)", "1.0", OPTION_FLOAT, "overall brightness scaling value for scanlines (multiplicative)" },
{ WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)", "0.0", OPTION_FLOAT, "overall brightness offset value for scanlines (additive)" },
{ WINOPTION_SCANLINE_OFFSET";fs_scanjt(0.0-4.0)", "0.0", OPTION_FLOAT, "overall interlace jitter scaling value for scanlines" },
{ WINOPTION_DEFOCUS";fs_focus", "0.0,0.0", OPTION_STRING, "overall defocus value in screen-relative coords" },
{ WINOPTION_CONVERGE_X";fs_convx", "0.3,0.0,-0.3",OPTION_STRING, "convergence in screen-relative X direction" },
{ WINOPTION_CONVERGE_Y";fs_convy", "0.0,0.3,-0.3",OPTION_STRING, "convergence in screen-relative Y direction" },
{ WINOPTION_RADIAL_CONVERGE_X";fs_rconvx", "0.0,0.0,0.0",OPTION_STRING, "radial convergence in screen-relative X direction" },
{ WINOPTION_RADIAL_CONVERGE_Y";fs_rconvy", "0.0,0.0,0.0",OPTION_STRING, "radial convergence in screen-relative Y direction" },
/* RGB colorspace convolution below this line */
{ WINOPTION_RED_RATIO";fs_redratio", "1.0,0.0,0.0",OPTION_STRING, "red output signal generated by input signal" },
{ WINOPTION_GRN_RATIO";fs_grnratio", "0.0,1.0,0.0",OPTION_STRING, "green output signal generated by input signal" },
{ WINOPTION_BLU_RATIO";fs_bluratio", "0.0,0.0,1.0",OPTION_STRING, "blue output signal generated by input signal" },
{ WINOPTION_SATURATION";fs_sat(0.0-4.0)", "1.4", OPTION_FLOAT, "saturation scaling value" },
{ WINOPTION_OFFSET";fs_offset", "0.0,0.0,0.0",OPTION_STRING, "signal offset value (additive)" },
{ WINOPTION_SCALE";fs_scale", "0.95,0.95,0.95",OPTION_STRING, "signal scaling value (multiplicative)" },
{ WINOPTION_POWER";fs_power", "0.8,0.8,0.8",OPTION_STRING, "signal power value (exponential)" },
{ WINOPTION_FLOOR";fs_floor", "0.05,0.05,0.05",OPTION_STRING, "signal floor level" },
{ WINOPTION_PHOSPHOR";fs_phosphor", "0.4,0.4,0.4",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" },
{ WINOPTION_YIQ_BVALUE";yiqb", "0.5", OPTION_FLOAT, "B value for NTSC signal processing" },
{ WINOPTION_YIQ_OVALUE";yiqo", "0.0", OPTION_FLOAT, "Outgoing Color Carrier phase offset for NTSC signal processing" },
{ WINOPTION_YIQ_PVALUE";yiqp", "1.0", OPTION_FLOAT, "Incoming Pixel Clock scaling value for NTSC signal processing" },
{ WINOPTION_YIQ_NVALUE";yiqn", "1.0", OPTION_FLOAT, "Y filter notch width for NTSC signal processing" },
{ WINOPTION_YIQ_YVALUE";yiqy", "6.0", OPTION_FLOAT, "Y filter cutoff frequency for NTSC signal processing" },
{ WINOPTION_YIQ_IVALUE";yiqi", "1.2", OPTION_FLOAT, "I filter cutoff frequency for NTSC signal processing" },
{ 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_LENGTH_SCALE";veclength", "0.8", OPTION_FLOAT, "How much length affects vector fade" },
{ WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "500.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
/* Bloom below this line */
{ NULL, NULL, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" },
{ WINOPTION_VECTOR_BLOOM_SCALE, "0.3", OPTION_FLOAT, "Intensity factor for vector bloom" },
{ WINOPTION_RASTER_BLOOM_SCALE, "0.225", OPTION_FLOAT, "Intensity factor for raster bloom" },
{ WINOPTION_BLOOM_LEVEL0_WEIGHT, "1.0", OPTION_FLOAT, "Bloom level 0 (full-size target) weight" },
{ WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.21", OPTION_FLOAT, "Bloom level 1 (half-size target) weight" },
{ WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.19", OPTION_FLOAT, "Bloom level 2 (quarter-size target) weight" },
{ WINOPTION_BLOOM_LEVEL3_WEIGHT, "0.17", OPTION_FLOAT, "Bloom level 3 (.) weight" },
{ WINOPTION_BLOOM_LEVEL4_WEIGHT, "0.15", OPTION_FLOAT, "Bloom level 4 (.) weight" },
{ WINOPTION_BLOOM_LEVEL5_WEIGHT, "0.14", OPTION_FLOAT, "Bloom level 5 (.) weight" },
{ WINOPTION_BLOOM_LEVEL6_WEIGHT, "0.13", OPTION_FLOAT, "Bloom level 6 (.) weight" },
{ WINOPTION_BLOOM_LEVEL7_WEIGHT, "0.12", OPTION_FLOAT, "Bloom level 7 (.) weight" },
{ WINOPTION_BLOOM_LEVEL8_WEIGHT, "0.11", OPTION_FLOAT, "Bloom level 8 (.) weight" },
{ WINOPTION_BLOOM_LEVEL9_WEIGHT, "0.10", OPTION_FLOAT, "Bloom level 9 (.) weight" },
{ WINOPTION_BLOOM_LEVEL10_WEIGHT, "0.09", OPTION_FLOAT, "Bloom level 10 (1x1 target) weight" },
// per-window options // per-window options
{ NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" }, { NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" },
{ WINOPTION_SCREEN, "auto", OPTION_STRING, "explicit name of all screens; 'auto' here will try to make a best guess" }, { WINOPTION_SCREEN, "auto", OPTION_STRING, "explicit name of all screens; 'auto' here will try to make a best guess" },

View File

@ -77,6 +77,74 @@
// Direct3D-specific options // Direct3D-specific options
#define WINOPTION_FILTER "filter" #define WINOPTION_FILTER "filter"
// core post-processing options
#define WINOPTION_HLSL_ENABLE "hlsl_enable"
#define WINOPTION_HLSLPATH "hlslpath"
#define WINOPTION_HLSL_INI_NAME "hlslini"
#define WINOPTION_HLSL_INI_WRITE "hlsl_ini_write"
#define WINOPTION_HLSL_INI_READ "hlsl_ini_read"
#define WINOPTION_HLSL_PRESCALE_X "hlsl_prescale_x"
#define WINOPTION_HLSL_PRESCALE_Y "hlsl_prescale_y"
#define WINOPTION_HLSL_PRESET "hlsl_preset"
#define WINOPTION_HLSL_WRITE "hlsl_write"
#define WINOPTION_HLSL_SNAP_WIDTH "hlsl_snap_width"
#define WINOPTION_HLSL_SNAP_HEIGHT "hlsl_snap_height"
#define WINOPTION_SHADOW_MASK_ALPHA "shadow_mask_alpha"
#define WINOPTION_SHADOW_MASK_TEXTURE "shadow_mask_texture"
#define WINOPTION_SHADOW_MASK_COUNT_X "shadow_mask_x_count"
#define WINOPTION_SHADOW_MASK_COUNT_Y "shadow_mask_y_count"
#define WINOPTION_SHADOW_MASK_USIZE "shadow_mask_usize"
#define WINOPTION_SHADOW_MASK_VSIZE "shadow_mask_vsize"
#define WINOPTION_PINCUSHION "pincushion"
#define WINOPTION_CURVATURE "curvature"
#define WINOPTION_SCANLINE_AMOUNT "scanline_alpha"
#define WINOPTION_SCANLINE_SCALE "scanline_size"
#define WINOPTION_SCANLINE_HEIGHT "scanline_height"
#define WINOPTION_SCANLINE_BRIGHT_SCALE "scanline_bright_scale"
#define WINOPTION_SCANLINE_BRIGHT_OFFSET "scanline_bright_offset"
#define WINOPTION_SCANLINE_OFFSET "scanline_jitter"
#define WINOPTION_DEFOCUS "defocus"
#define WINOPTION_CONVERGE_X "converge_x"
#define WINOPTION_CONVERGE_Y "converge_y"
#define WINOPTION_RADIAL_CONVERGE_X "radial_converge_x"
#define WINOPTION_RADIAL_CONVERGE_Y "radial_converge_y"
#define WINOPTION_RED_RATIO "red_ratio"
#define WINOPTION_GRN_RATIO "grn_ratio"
#define WINOPTION_BLU_RATIO "blu_ratio"
#define WINOPTION_OFFSET "offset"
#define WINOPTION_SCALE "scale"
#define WINOPTION_POWER "power"
#define WINOPTION_FLOOR "floor"
#define WINOPTION_PHOSPHOR "phosphor_life"
#define WINOPTION_SATURATION "saturation"
#define WINOPTION_YIQ_ENABLE "yiq_enable"
#define WINOPTION_YIQ_CCVALUE "yiq_cc"
#define WINOPTION_YIQ_AVALUE "yiq_a"
#define WINOPTION_YIQ_BVALUE "yiq_b"
#define WINOPTION_YIQ_OVALUE "yiq_o"
#define WINOPTION_YIQ_PVALUE "yiq_p"
#define WINOPTION_YIQ_NVALUE "yiq_n"
#define WINOPTION_YIQ_YVALUE "yiq_y"
#define WINOPTION_YIQ_IVALUE "yiq_i"
#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_LENGTH_SCALE "vector_length_scale"
#define WINOPTION_VECTOR_LENGTH_RATIO "vector_length_ratio"
#define WINOPTION_VECTOR_BLOOM_SCALE "vector_bloom_scale"
#define WINOPTION_RASTER_BLOOM_SCALE "raster_bloom_scale"
#define WINOPTION_BLOOM_LEVEL0_WEIGHT "bloom_lvl0_weight"
#define WINOPTION_BLOOM_LEVEL1_WEIGHT "bloom_lvl1_weight"
#define WINOPTION_BLOOM_LEVEL2_WEIGHT "bloom_lvl2_weight"
#define WINOPTION_BLOOM_LEVEL3_WEIGHT "bloom_lvl3_weight"
#define WINOPTION_BLOOM_LEVEL4_WEIGHT "bloom_lvl4_weight"
#define WINOPTION_BLOOM_LEVEL5_WEIGHT "bloom_lvl5_weight"
#define WINOPTION_BLOOM_LEVEL6_WEIGHT "bloom_lvl6_weight"
#define WINOPTION_BLOOM_LEVEL7_WEIGHT "bloom_lvl7_weight"
#define WINOPTION_BLOOM_LEVEL8_WEIGHT "bloom_lvl8_weight"
#define WINOPTION_BLOOM_LEVEL9_WEIGHT "bloom_lvl9_weight"
#define WINOPTION_BLOOM_LEVEL10_WEIGHT "bloom_lvl10_weight"
// per-window options // per-window options
#define WINOPTION_SCREEN "screen" #define WINOPTION_SCREEN "screen"
#define WINOPTION_ASPECT "aspect" #define WINOPTION_ASPECT "aspect"
@ -138,6 +206,74 @@ public:
// Direct3D-specific options // Direct3D-specific options
bool filter() const { return bool_value(WINOPTION_FILTER); } bool filter() const { return bool_value(WINOPTION_FILTER); }
// core post-processing options
const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); }
const char *hlsl_ini_name() const { return value(WINOPTION_HLSL_INI_NAME); }
bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); }
bool hlsl_write_ini() const { return bool_value(WINOPTION_HLSL_INI_WRITE); }
bool hlsl_read_ini() const { return bool_value(WINOPTION_HLSL_INI_READ); }
const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); }
int d3d_hlsl_prescale_x() const { return int_value(WINOPTION_HLSL_PRESCALE_X); }
int d3d_hlsl_prescale_y() const { return int_value(WINOPTION_HLSL_PRESCALE_Y); }
int d3d_hlsl_preset() const { return int_value(WINOPTION_HLSL_PRESET); }
int d3d_snap_width() const { return int_value(WINOPTION_HLSL_SNAP_WIDTH); }
int d3d_snap_height() const { return int_value(WINOPTION_HLSL_SNAP_HEIGHT); }
float screen_shadow_mask_alpha() const { return float_value(WINOPTION_SHADOW_MASK_ALPHA); }
const char *screen_shadow_mask_texture() const { return value(WINOPTION_SHADOW_MASK_TEXTURE); }
int screen_shadow_mask_count_x() const { return int_value(WINOPTION_SHADOW_MASK_COUNT_X); }
int screen_shadow_mask_count_y() const { return int_value(WINOPTION_SHADOW_MASK_COUNT_Y); }
float screen_shadow_mask_u_size() const { return float_value(WINOPTION_SHADOW_MASK_USIZE); }
float screen_shadow_mask_v_size() const { return float_value(WINOPTION_SHADOW_MASK_VSIZE); }
float screen_scanline_amount() const { return float_value(WINOPTION_SCANLINE_AMOUNT); }
float screen_scanline_scale() const { return float_value(WINOPTION_SCANLINE_SCALE); }
float screen_scanline_height() const { return float_value(WINOPTION_SCANLINE_HEIGHT); }
float screen_scanline_bright_scale() const { return float_value(WINOPTION_SCANLINE_BRIGHT_SCALE); }
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_curvature() const { return float_value(WINOPTION_CURVATURE); }
const char *screen_defocus() const { return value(WINOPTION_DEFOCUS); }
const char *screen_converge_x() const { return value(WINOPTION_CONVERGE_X); }
const char *screen_converge_y() const { return value(WINOPTION_CONVERGE_Y); }
const char *screen_radial_converge_x() const { return value(WINOPTION_RADIAL_CONVERGE_X); }
const char *screen_radial_converge_y() const { return value(WINOPTION_RADIAL_CONVERGE_Y); }
const char *screen_red_ratio() const { return value(WINOPTION_RED_RATIO); }
const char *screen_grn_ratio() const { return value(WINOPTION_GRN_RATIO); }
const char *screen_blu_ratio() const { return value(WINOPTION_BLU_RATIO); }
bool screen_yiq_enable() const { return bool_value(WINOPTION_YIQ_ENABLE); }
float screen_yiq_cc() const { return float_value(WINOPTION_YIQ_CCVALUE); }
float screen_yiq_a() const { return float_value(WINOPTION_YIQ_AVALUE); }
float screen_yiq_b() const { return float_value(WINOPTION_YIQ_BVALUE); }
float screen_yiq_o() const { return float_value(WINOPTION_YIQ_OVALUE); }
float screen_yiq_p() const { return float_value(WINOPTION_YIQ_PVALUE); }
float screen_yiq_n() const { return float_value(WINOPTION_YIQ_NVALUE); }
float screen_yiq_y() const { return float_value(WINOPTION_YIQ_YVALUE); }
float screen_yiq_i() const { return float_value(WINOPTION_YIQ_IVALUE); }
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_length_scale() const { return float_value(WINOPTION_VECTOR_LENGTH_SCALE); }
float screen_vector_length_ratio() const { return float_value(WINOPTION_VECTOR_LENGTH_RATIO); }
float screen_vector_bloom_scale() const { return float_value(WINOPTION_VECTOR_BLOOM_SCALE); }
float screen_raster_bloom_scale() const { return float_value(WINOPTION_RASTER_BLOOM_SCALE); }
float screen_bloom_lvl0_weight() const { return float_value(WINOPTION_BLOOM_LEVEL0_WEIGHT); }
float screen_bloom_lvl1_weight() const { return float_value(WINOPTION_BLOOM_LEVEL1_WEIGHT); }
float screen_bloom_lvl2_weight() const { return float_value(WINOPTION_BLOOM_LEVEL2_WEIGHT); }
float screen_bloom_lvl3_weight() const { return float_value(WINOPTION_BLOOM_LEVEL3_WEIGHT); }
float screen_bloom_lvl4_weight() const { return float_value(WINOPTION_BLOOM_LEVEL4_WEIGHT); }
float screen_bloom_lvl5_weight() const { return float_value(WINOPTION_BLOOM_LEVEL5_WEIGHT); }
float screen_bloom_lvl6_weight() const { return float_value(WINOPTION_BLOOM_LEVEL6_WEIGHT); }
float screen_bloom_lvl7_weight() const { return float_value(WINOPTION_BLOOM_LEVEL7_WEIGHT); }
float screen_bloom_lvl8_weight() const { return float_value(WINOPTION_BLOOM_LEVEL8_WEIGHT); }
float screen_bloom_lvl9_weight() const { return float_value(WINOPTION_BLOOM_LEVEL9_WEIGHT); }
float screen_bloom_lvl10_weight() const { return float_value(WINOPTION_BLOOM_LEVEL10_WEIGHT); }
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); }
const char *screen_floor() const { return value(WINOPTION_FLOOR); }
const char *screen_phosphor() const { return value(WINOPTION_PHOSPHOR); }
float screen_saturation() const { return float_value(WINOPTION_SATURATION); }
// per-window options // per-window options
const char *screen() const { return value(WINOPTION_SCREEN); } const char *screen() const { return value(WINOPTION_SCREEN); }
const char *aspect() const { return value(WINOPTION_ASPECT); } const char *aspect() const { return value(WINOPTION_ASPECT); }
@ -202,6 +338,9 @@ public:
virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
virtual void set_mastervolume(int attenuation); virtual void set_mastervolume(int attenuation);
// video overridables
virtual void *get_slider_list();
// input overridables // input overridables
virtual void customize_input_type_list(simple_list<input_type_entry> &typelist); virtual void customize_input_type_list(simple_list<input_type_entry> &typelist);
@ -210,12 +349,7 @@ public:
virtual void font_close(osd_font font); virtual void font_close(osd_font font);
virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
virtual void set_shader_system(void *shader_system) { m_shader_system = shader_system; }
virtual void *shader_system() { return m_shader_system; }
private: private:
void * m_shader_system;
static void osd_exit(running_machine &machine); static void osd_exit(running_machine &machine);
static const int DEFAULT_FONT_HEIGHT = 200; static const int DEFAULT_FONT_HEIGHT = 200;