From 7e652d13c538f96ee0d43207cd373e4f53d06805 Mon Sep 17 00:00:00 2001 From: Ryan Holtz Date: Mon, 31 Dec 2012 21:29:02 +0000 Subject: - render.c: Added new PRIMFLAG macros pertaining to vectors, to be used by the OSD. [MooglyGuy] - d3dhlsl.c: Began laying the groundwork for vector post-processing, disabled by default. [MooglyGuy] --- src/osd/windows/d3dhlsl.c | 109 +++++++++++++++++++++++++++++++++++++--------- src/osd/windows/d3dhlsl.h | 35 ++++++++++----- src/osd/windows/drawd3d.c | 13 +++++- src/osd/windows/drawd3d.h | 4 -- 4 files changed, 124 insertions(+), 37 deletions(-) (limited to 'src/osd') diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c index cc76f96cf57..2ed0787bfda 100644 --- a/src/osd/windows/d3dhlsl.c +++ b/src/osd/windows/d3dhlsl.c @@ -191,6 +191,7 @@ static file_error open_next(d3d_info *d3d, emu_file &file, const char *templ, co hlsl_info::hlsl_info() { master_enable = false; + vector_enable = true; prescale_size_x = 1; prescale_size_y = 1; prescale_force_x = 0; @@ -1062,44 +1063,45 @@ int hlsl_info::create_resources() g_slider_list = init_slider_list(); const char *fx_dir = downcast(window->machine().options()).screen_post_fx_dir(); - char primary_name_cstr[1024]; - char post_name_cstr[1024]; - char prescale_name_cstr[1024]; - char pincushion_name_cstr[1024]; - char phosphor_name_cstr[1024]; - char focus_name_cstr[1024]; - char deconverge_name_cstr[1024]; - char color_name_cstr[1024]; - char yiq_encode_name_cstr[1024]; - char yiq_decode_name_cstr[1024]; + // Replace all this garbage with a proper data-driven system + char primary_name_cstr[1024]; sprintf(primary_name_cstr, "%s\\primary.fx", fx_dir); TCHAR *primary_name = tstring_from_utf8(primary_name_cstr); + char post_name_cstr[1024]; sprintf(post_name_cstr, "%s\\post.fx", fx_dir); TCHAR *post_name = tstring_from_utf8(post_name_cstr); + char prescale_name_cstr[1024]; sprintf(prescale_name_cstr, "%s\\prescale.fx", fx_dir); TCHAR *prescale_name = tstring_from_utf8(prescale_name_cstr); + char pincushion_name_cstr[1024]; sprintf(pincushion_name_cstr, "%s\\pincushion.fx", fx_dir); TCHAR *pincushion_name = tstring_from_utf8(pincushion_name_cstr); + char phosphor_name_cstr[1024]; sprintf(phosphor_name_cstr, "%s\\phosphor.fx", fx_dir); TCHAR *phosphor_name = tstring_from_utf8(phosphor_name_cstr); + char focus_name_cstr[1024]; sprintf(focus_name_cstr, "%s\\focus.fx", fx_dir); TCHAR *focus_name = tstring_from_utf8(focus_name_cstr); + char deconverge_name_cstr[1024]; sprintf(deconverge_name_cstr, "%s\\deconverge.fx", fx_dir); TCHAR *deconverge_name = tstring_from_utf8(deconverge_name_cstr); + char color_name_cstr[1024]; sprintf(color_name_cstr, "%s\\color.fx", fx_dir); TCHAR *color_name = tstring_from_utf8(color_name_cstr); + char yiq_encode_name_cstr[1024]; sprintf(yiq_encode_name_cstr, "%s\\yiq_encode.fx", fx_dir); TCHAR *yiq_encode_name = tstring_from_utf8(yiq_encode_name_cstr); + char yiq_decode_name_cstr[1024]; sprintf(yiq_decode_name_cstr, "%s\\yiq_decode.fx", fx_dir); TCHAR *yiq_decode_name = tstring_from_utf8(yiq_decode_name_cstr); @@ -1183,6 +1185,22 @@ int hlsl_info::create_resources() return 1; } + // 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); + + result = (*d3dintf->device.create_effect)(d3d->device, vector_name, &vector_effect); + if(result != D3D_OK) + { + mame_printf_verbose("Direct3D: Unable to load vector.fx\n"); + return 1; + } + if (vector_name) + osd_free(vector_name); +#endif + if (primary_name) osd_free(primary_name); if (post_name) @@ -1367,6 +1385,16 @@ 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); @@ -1782,6 +1810,11 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) options->params_dirty = false; } +#if HLSL_VECTOR + else if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable) + { + } +#endif else { (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f); @@ -1863,20 +1896,48 @@ 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) +{ +#if HLSL_VECTOR + if (!vector_enable) + { + return false; + } + + 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) +{ +#if HLSL_VECTOR + if (!add_render_target(d3d, NULL, d3d->width, d3d->height, 1, 1)) + { + vector_enable = false; + } +#endif +} + //============================================================ // 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) { - if (find_render_target(info)) + UINT32 screen_index = 0; + UINT32 page_index = 0; + if (info != NULL) { - remove_render_target(info); - } + if (find_render_target(info)) + { + remove_render_target(info); + } - UINT32 screen_index_data = (UINT32)info->texinfo.osddata; - UINT32 screen_index = screen_index_data >> 1; - UINT32 page_index = screen_index_data & 1; + UINT32 screen_index_data = (UINT32)info->texinfo.osddata; + screen_index = screen_index_data >> 1; + page_index = screen_index_data & 1; + } d3d_render_target* target = (d3d_render_target*)global_alloc_clear(d3d_render_target); @@ -1886,15 +1947,21 @@ bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int wid return false; } - target->info = info; - - 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->screen_index = screen_index; target->page_index = page_index; - d3d_cache_target* cache = find_cache_target(target->screen_index, info->texinfo.width, info->texinfo.height); + d3d_cache_target* cache = find_cache_target(target->screen_index, target->width, target->height); if (cache == NULL) { if (!add_cache_target(d3d, info, width, height, xprescale, yprescale, target->screen_index)) diff --git a/src/osd/windows/d3dhlsl.h b/src/osd/windows/d3dhlsl.h index 84bdaed1fc4..881e6e52106 100644 --- a/src/osd/windows/d3dhlsl.h +++ b/src/osd/windows/d3dhlsl.h @@ -44,6 +44,12 @@ #include "aviio.h" +//============================================================ +// CONSTANTS +//============================================================ + +#define HLSL_VECTOR (0) + //============================================================ // TYPE DEFINITIONS //============================================================ @@ -111,6 +117,10 @@ public: bool enabled() { return master_enable; } + 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); + void begin(); void init_effect_info(d3d_poly_info *poly); void render_quad(d3d_poly_info *poly, int vertnum); @@ -159,6 +169,7 @@ private: 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 @@ -193,20 +204,24 @@ private: d3d_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 // HLSL effects d3d_surface * backbuffer; // pointer to our device's backbuffer d3d_effect * curr_effect; // pointer to the currently active effect object - d3d_effect * effect; // pointer to the current primary-effect object - d3d_effect * prescale_effect; // pointer to the current prescale-effect object - d3d_effect * post_effect; // pointer to the current post-effect object - d3d_effect * pincushion_effect; // pointer to the current pincushion-effect object - d3d_effect * focus_effect; // pointer to the current focus-effect object - d3d_effect * phosphor_effect; // pointer to the current phosphor-effect object - d3d_effect * deconverge_effect; // pointer to the current deconvergence-effect object - 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_effect * effect; // pointer to the primary-effect object + d3d_effect * prescale_effect; // pointer to the prescale-effect object + d3d_effect * post_effect; // pointer to the post-effect object + d3d_effect * pincushion_effect; // pointer to the pincushion-effect object + d3d_effect * focus_effect; // pointer to the focus-effect object + d3d_effect * phosphor_effect; // pointer to the phosphor-effect object + d3d_effect * deconverge_effect; // pointer to the deconvergence-effect object + d3d_effect * color_effect; // pointer to the color-effect object + 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 * vector_effect; // pointer to the vector-effect object +#endif d3d_vertex * fsfx_vertices; // pointer to our full-screen-quad object public: diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index ec92033cbe5..024f437a3ad 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -584,8 +584,19 @@ mtlog_add("drawd3d_window_draw: begin"); // first update any textures window->primlist->acquire_lock(); for (prim = window->primlist->first(); prim != NULL; prim = prim->next()) + { if (prim->texture.base != NULL) + { texture_update(d3d, prim); + } + else if(d3d->hlsl->vector_enabled() && PRIMFLAG_GET_VECTORBUF(prim->flags)) + { + if (!d3d->hlsl->get_vector_target(d3d)) + { + d3d->hlsl->create_vector_target(d3d, prim); + } + } + } // begin the scene mtlog_add("drawd3d_window_draw: begin_scene"); @@ -1846,7 +1857,6 @@ d3d_texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsource, { if (d3d->hlsl->enabled() && !d3d->hlsl->register_prescaled_texture(texture)) { - printf("hlsl issue 2\n"); goto error; } break; @@ -2590,7 +2600,6 @@ static d3d_texture_info *texture_find(d3d_info *d3d, const render_primitive *pri } - //============================================================ // texture_update //============================================================ diff --git a/src/osd/windows/drawd3d.h b/src/osd/windows/drawd3d.h index b6ec8371c24..fb590a9bd82 100644 --- a/src/osd/windows/drawd3d.h +++ b/src/osd/windows/drawd3d.h @@ -53,8 +53,6 @@ #define VERTEX_BASE_FORMAT (D3DFVF_DIFFUSE | D3DFVF_TEX1) #define VERTEX_BUFFER_SIZE (2048*4+4) - - //============================================================ // TYPE DEFINITIONS //============================================================ @@ -109,8 +107,6 @@ public: d3d_surface *target[5]; d3d_texture *texture[5]; - d3d_texture_info *info; - d3d_render_target *next; d3d_render_target *prev; }; -- cgit v1.2.3