diff options
author | couriersud <couriersud@arcor.de> | 2015-02-11 19:59:43 +0100 |
---|---|---|
committer | couriersud <couriersud@arcor.de> | 2015-02-11 19:59:43 +0100 |
commit | e444a829ead84d60d0326d646cd3063d5d4395a6 (patch) | |
tree | c5cfc5c074871c145841a9ddeb3979ad098e3800 | |
parent | c8ee57681aa99a0f110a6ea4ee7a27350dc87400 (diff) |
More osd_window migration. (nw)
-rw-r--r-- | src/osd/sdl/draw13.c | 12 | ||||
-rw-r--r-- | src/osd/sdl/drawogl.c | 56 | ||||
-rw-r--r-- | src/osd/sdl/drawsdl.c | 16 | ||||
-rw-r--r-- | src/osd/sdl/window.c | 30 | ||||
-rw-r--r-- | src/osd/sdl/window.h | 56 | ||||
-rw-r--r-- | src/osd/windows/d3dcomm.h | 2 | ||||
-rw-r--r-- | src/osd/windows/d3dhlsl.c | 85 | ||||
-rw-r--r-- | src/osd/windows/d3dhlsl.h | 6 | ||||
-rw-r--r-- | src/osd/windows/drawbgfx.c | 4 | ||||
-rw-r--r-- | src/osd/windows/drawd3d.c | 35 | ||||
-rw-r--r-- | src/osd/windows/drawd3d.h | 4 | ||||
-rw-r--r-- | src/osd/windows/drawdd.c | 20 | ||||
-rw-r--r-- | src/osd/windows/drawgdi.c | 4 | ||||
-rw-r--r-- | src/osd/windows/drawnone.c | 4 | ||||
-rw-r--r-- | src/osd/windows/window.c | 3 | ||||
-rw-r--r-- | src/osd/windows/window.h | 27 |
16 files changed, 180 insertions, 184 deletions
diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c index 42009477dff..aecf35ef3be 100644 --- a/src/osd/sdl/draw13.c +++ b/src/osd/sdl/draw13.c @@ -68,7 +68,7 @@ struct quad_setup_data : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), rotwidth(0), rotheight(0) {} - void compute(const render_primitive &prim); + void compute(const render_primitive &prim, const int prescale); INT32 dudx, dvdx, dudy, dvdy; INT32 startu, startv; @@ -142,7 +142,7 @@ private: class sdl_info13 : public osd_renderer { public: - sdl_info13(sdl_window_info *w) + sdl_info13(osd_window *w) : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_renderer(NULL), m_last_hofs(0), m_last_vofs(0), m_width(0), m_height(0), @@ -501,7 +501,7 @@ static void expand_copy_info(copy_info_t *list) } } -static osd_renderer *drawsdl2_create(sdl_window_info *window) +static osd_renderer *drawsdl2_create(osd_window *window) { return global_alloc(sdl_info13(window)); } @@ -988,7 +988,7 @@ void texture_info::set_data(const render_texinfo &texsource, const UINT32 flags) // compute rotation setup //============================================================ -void quad_setup_data::compute(const render_primitive &prim) +void quad_setup_data::compute(const render_primitive &prim, const int prescale) { const render_quad_texuv *texcoords = &prim.texcoords; int texwidth = prim.texture.width; @@ -998,7 +998,7 @@ void quad_setup_data::compute(const render_primitive &prim) float fscale; /* determine U/V deltas */ if ((PRIMFLAG_GET_SCREENTEX(prim.flags))) - fscale = (float) video_config.prescale; + fscale = (float) prescale; else fscale = 1.0f; @@ -1081,7 +1081,7 @@ texture_info * sdl_info13::texture_update(const render_primitive &prim) quad_setup_data setup; texture_info *texture; - setup.compute(prim); + setup.compute(prim, window().prescale()); texture = texture_find(prim, setup); diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c index c7477a6bedf..3de7d632e87 100644 --- a/src/osd/sdl/drawogl.c +++ b/src/osd/sdl/drawogl.c @@ -221,9 +221,8 @@ public: class sdl_info_ogl : public osd_renderer { public: - sdl_info_ogl(sdl_window_info *window) + sdl_info_ogl(osd_window *window) : osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0), - m_screen_width(0), m_screen_height(0), m_width(0), m_height(0), m_blitwidth(0), m_blitheight(0), #if (SDLMAME_SDL2) @@ -292,8 +291,6 @@ private: void texture_all_disable(); INT32 m_blittimer; - int m_screen_width; - int m_screen_height; int m_width; int m_height; int m_blitwidth; @@ -462,7 +459,7 @@ static int dll_loaded = 0; // drawsdl_init //============================================================ -static osd_renderer *drawogl_create(sdl_window_info *window) +static osd_renderer *drawogl_create(osd_window *window) { return global_alloc(sdl_info_ogl(window)); } @@ -745,9 +742,6 @@ int sdl_info_ogl::create() #else #endif - m_screen_width = 0; - m_screen_height = 0; - m_blittimer = 0; m_surf_w = 0; m_surf_h = 0; @@ -1210,8 +1204,7 @@ int sdl_info_ogl::draw(UINT32 dc, int update) render_primitive *prim; texture_info *texture=NULL; float vofs, hofs; - int pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE, scrnum, is_vector; - const screen_device *screen; + int pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE; int width = 0; int height = 0; if (video_config.novideo) @@ -1233,26 +1226,6 @@ int sdl_info_ogl::draw(UINT32 dc, int update) #if (SDLMAME_SDL2) SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id); -#else - if (!m_init_context) - { - screen_device_iterator myiter(window().machine().root_device()); - for (screen = myiter.first(); screen != NULL; screen = myiter.next()) - { - if (window().index() == 0) - { - if ((screen->width() != m_screen_width) || (screen->height() != m_screen_height)) - { - m_screen_width = screen->width(); - m_screen_height = screen->height(); - - // force all textures to be regenerated - destroy_all_textures(); - } - break; - } - } - } #endif if (m_init_context) @@ -1271,24 +1244,8 @@ int sdl_info_ogl::draw(UINT32 dc, int update) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } - // figure out if we're vector - scrnum = is_vector = 0; - screen_device_iterator iter(window().machine().root_device()); - for (screen = iter.first(); screen != NULL; screen = iter.next()) - { - if (scrnum == window().index()) - { - is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0; - break; - } - else - { - scrnum++; - } - } - // only clear if the geometry changes (and for 2 frames afterward to clear double and triple buffers) - if ((m_blittimer > 0) || (is_vector)) + if ((m_blittimer > 0) || has_flags(FLAG_HAS_VECTOR_SCREEN)) { glClear(GL_COLOR_BUFFER_BIT); m_blittimer--; @@ -1304,6 +1261,11 @@ int sdl_info_ogl::draw(UINT32 dc, int update) loadGLExtensions(); } +#if (!SDLMAME_SDL2) + // force all textures to be regenerated + destroy_all_textures(); +#endif + m_surf_w = m_width; m_surf_h = m_height; diff --git a/src/osd/sdl/drawsdl.c b/src/osd/sdl/drawsdl.c index 222b2b0fc20..19bb5ceb6f8 100644 --- a/src/osd/sdl/drawsdl.c +++ b/src/osd/sdl/drawsdl.c @@ -50,7 +50,7 @@ class sdl_info : public osd_renderer { public: - sdl_info(sdl_window_info *w, int extra_flags) + sdl_info(osd_window *w, int extra_flags) : osd_renderer(w, extra_flags), #if (SDLMAME_SDL2) m_sdl_renderer(NULL), @@ -227,7 +227,7 @@ int drawsdl_scale_mode(const char *s) } -static osd_renderer *drawsdl_create(sdl_window_info *window) +static osd_renderer *drawsdl_create(osd_window *window) { // FIXME: QUALITY HINTS #if (SDLMAME_SDL2) @@ -292,10 +292,10 @@ void sdl_info::setup_texture(int tempwidth, int tempheight) int m_hw_scale_height = 0; window().target()->compute_minimum_size(m_hw_scale_width, m_hw_scale_height); - if (video_config.prescale) + if (window().prescale()) { - m_hw_scale_width *= video_config.prescale; - m_hw_scale_height *= video_config.prescale; + m_hw_scale_width *= window().prescale(); + m_hw_scale_height *= window().prescale(); /* This must be a multiple of 2 */ m_hw_scale_width = (m_hw_scale_width + 1) & ~1; @@ -329,10 +329,10 @@ void sdl_info::yuv_overlay_init() window().target()->compute_minimum_size(minimum_width, minimum_height); - if (video_config.prescale) + if (window().prescale()) { - minimum_width *= video_config.prescale; - minimum_height *= video_config.prescale; + minimum_width *= window().prescale(); + minimum_height *= window().prescale(); } if (m_yuvsurf != NULL) diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c index 5cc6c06a05d..60750f1fe63 100644 --- a/src/osd/sdl/window.c +++ b/src/osd/sdl/window.c @@ -1017,6 +1017,9 @@ void sdl_window_info::update() // if we're visible and running and not in the middle of a resize, draw if (m_target != NULL) { + + + int tempwidth, tempheight; // see if the games video mode has changed @@ -1327,6 +1330,33 @@ OSDWORK_CALLBACK( sdl_window_info::draw_video_contents_wt ) // Some configurations require events to be polled in the worker thread sdlinput_process_events_buf(); + // Check whether window has vector screens + + { +#if 1 + int scrnum = 0; + int is_vector = 0; + screen_device_iterator iter(window->machine().root_device()); + for (const screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) + { + if (scrnum == window->m_index) + { + is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0; + break; + } + else + { + scrnum++; + } + } + if (is_vector) + window->renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN); + else + window->renderer().clear_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN); +#endif + } + + window->m_primlist = wp->list(); // if no bitmap, just fill diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index 1e3e7934fa4..c582d09cf7d 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -36,30 +36,54 @@ class osd_window { public: osd_window() - : m_primlist(NULL), - m_start_viewscreen(0) + : +#ifdef OSD_SDL + m_start_viewscreen(0), +#else + m_hwnd(0), m_focus_hwnd(0), m_monitor(NULL), m_resize_state(0), + m_maxwidth(0), m_maxheight(0), + m_refresh(0), +#endif + m_prescale(1), + m_primlist(NULL) {} virtual ~osd_window() { } + + virtual render_target *target() = 0; + virtual int fullscreen() const = 0; + virtual running_machine &machine() const = 0; + + int prescale() const { return m_prescale; }; + #ifdef OSD_SDL virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0; virtual sdl_monitor_info *monitor() const = 0; - virtual render_target *target() = 0; virtual void get_size(int &w, int &h) = 0; - virtual int fullscreen() const = 0; - virtual int index() const = 0; - virtual int prescale() const = 0; #if (SDLMAME_SDL2) virtual SDL_Window *sdl_window() = 0; #else virtual SDL_Surface *sdl_surface() = 0; #endif - virtual running_machine &machine() const = 0; + int m_start_viewscreen; - render_primitive_list *m_primlist; - int m_start_viewscreen; +#else + virtual bool win_has_menu() = 0; + virtual win_monitor_info *winwindow_video_window_monitor(const RECT *proposed) = 0; + // window handle and info + HWND m_hwnd; + HWND m_focus_hwnd; + + // monitor info + win_monitor_info * m_monitor; + int m_resize_state; + int m_maxwidth, m_maxheight; + int m_refresh; #endif + + int m_prescale; + render_primitive_list *m_primlist; }; class osd_renderer @@ -69,6 +93,7 @@ public: /* Generic flags */ static const int FLAG_NONE = 0x0000; static const int FLAG_NEEDS_OPENGL = 0x0001; + static const int FLAG_HAS_VECTOR_SCREEN = 0x0002; #if (!(SDLMAME_SDL2)) /* SDL 1.2 flags */ @@ -82,8 +107,10 @@ public: virtual ~osd_renderer() { } osd_window &window() { return *m_window; } - int flags() const { return m_flags; } bool has_flags(const int flag) { return ((m_flags & flag)) == flag; } + void set_flags(int aflag) { m_flags |= aflag; } + void clear_flags(int aflag) { m_flags &= ~aflag; } + void notify_changed() { set_flags(FI_CHANGED); } @@ -108,9 +135,6 @@ protected: /* Internal flags */ static const int FI_CHANGED = 0x010000; - void set_flags(int aflag) { m_flags |= aflag; } - void clear_flags(int aflag) { m_flags &= ~aflag; } - private: osd_window *m_window; @@ -185,8 +209,6 @@ public: sdl_monitor_info *monitor() const { return m_monitor; } int fullscreen() const { return m_fullscreen; } - int index() const { return m_index; } - render_target *target() { return m_target; } #if (SDLMAME_SDL2) SDL_Window *sdl_window() { return m_sdl_window; } @@ -224,8 +246,6 @@ private: osd_event * m_rendered_event; render_target * m_target; - int m_prescale; - #if (SDLMAME_SDL2) // Needs to be here as well so we can identify window SDL_Window *m_sdl_window; @@ -278,7 +298,7 @@ private: struct osd_draw_callbacks { - osd_renderer *(*create)(sdl_window_info *window); + osd_renderer *(*create)(osd_window *window); void (*exit)(void); }; diff --git a/src/osd/windows/d3dcomm.h b/src/osd/windows/d3dcomm.h index ae68103931f..dd5e6b5f86c 100644 --- a/src/osd/windows/d3dcomm.h +++ b/src/osd/windows/d3dcomm.h @@ -108,7 +108,7 @@ private: class texture_info { public: - texture_info(texture_manager *manager, const render_texinfo *texsource, UINT32 flags); + texture_info(texture_manager *manager, const render_texinfo *texsource, int prescale, UINT32 flags); ~texture_info(); render_texinfo & get_texinfo() { return m_texinfo; } diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c index 5a6772e9281..8a10a105e76 100644 --- a/src/osd/windows/d3dhlsl.c +++ b/src/osd/windows/d3dhlsl.c @@ -224,8 +224,6 @@ void shaders::window_save() if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), snap_width, snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &snap_copy_texture); if (result != D3D_OK) { @@ -257,7 +255,7 @@ void shaders::window_record() if (!master_enable || !d3dintf->post_fx_available) return; - windows_options &options = downcast<windows_options &>(window->machine().options()); + windows_options &options = downcast<windows_options &>(machine->options()); const char *filename = options.d3d_hlsl_write(); if (avi_output_file != NULL) @@ -276,8 +274,6 @@ void shaders::avi_update_snap(surface *surface) if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - D3DLOCKED_RECT rect; // if we don't have a bitmap, or if it's not the right size, allocate a new one @@ -326,8 +322,6 @@ void shaders::render_snapshot(surface *surface) if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - D3DLOCKED_RECT rect; render_snap = false; @@ -370,14 +364,14 @@ void shaders::render_snapshot(surface *surface) int idx = cy * 2 + cx; - emu_file file(window->machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); + emu_file file(machine->options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); file_error filerr = open_next(d3d, file, NULL, "png", idx); if (filerr != FILERR_NONE) return; // add two text entries describing the image astring text1(emulator_info::get_appname(), " ", build_version); - astring text2(window->machine().system().manufacturer, " ", window->machine().system().description); + astring text2(machine->system().manufacturer, " ", machine->system().description); png_info pnginfo = { 0 }; png_add_text(&pnginfo, "Software", text1); png_add_text(&pnginfo, "System", text2); @@ -438,7 +432,7 @@ void shaders::record_texture() return; // get the current time - attotime curtime = window->machine().time(); + attotime curtime = machine->time(); avi_update_snap(surface); @@ -519,19 +513,17 @@ void shaders::begin_avi_recording(const char *name) if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - // stop any existing recording end_avi_recording(); // reset the state avi_frame = 0; - avi_next_frame_time = window->machine().time(); + avi_next_frame_time = machine->time(); // build up information about this new movie avi_movie_info info; info.video_format = 0; - info.video_timescale = 1000 * ((window->machine().first_screen() != NULL) ? ATTOSECONDS_TO_HZ(window->machine().first_screen()->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE); + info.video_timescale = 1000 * ((machine->first_screen() != NULL) ? ATTOSECONDS_TO_HZ(machine->first_screen()->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE); info.video_sampletime = 1000; info.video_numsamples = 0; info.video_width = snap_width; @@ -539,18 +531,18 @@ void shaders::begin_avi_recording(const char *name) info.video_depth = 24; info.audio_format = 0; - info.audio_timescale = window->machine().sample_rate(); + info.audio_timescale = machine->sample_rate(); info.audio_sampletime = 1; info.audio_numsamples = 0; info.audio_channels = 2; info.audio_samplebits = 16; - info.audio_samplerate = window->machine().sample_rate(); + info.audio_samplerate = machine->sample_rate(); // create a new temporary movie file file_error filerr; astring fullpath; { - emu_file tempfile(window->machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); + emu_file tempfile(machine->options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (name != NULL) { filerr = tempfile.open(name); @@ -678,8 +670,6 @@ void shaders::set_texture(texture_info *texture) if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - if(texture != NULL) { paused = texture->paused(); @@ -699,7 +689,7 @@ void shaders::set_texture(texture_info *texture) // shaders::init //============================================================ -void shaders::init(base *d3dintf, win_window_info *window) +void shaders::init(base *d3dintf, running_machine *machine, d3d::renderer *renderer) { if (!d3dintf->post_fx_available) return; @@ -713,28 +703,29 @@ void shaders::init(base *d3dintf, win_window_info *window) } this->d3dintf = d3dintf; - this->window = window; + this->machine = machine; + this->d3d = renderer; - master_enable = downcast<windows_options &>(window->machine().options()).d3d_hlsl_enable(); + master_enable = downcast<windows_options &>(machine->options()).d3d_hlsl_enable(); prescale_size_x = 1; prescale_size_y = 1; - preset = downcast<windows_options &>(window->machine().options()).d3d_hlsl_preset(); + preset = downcast<windows_options &>(machine->options()).d3d_hlsl_preset(); if (preset < -1 || preset > 3) { preset = -1; } - snap_width = downcast<windows_options &>(window->machine().options()).d3d_snap_width(); - snap_height = downcast<windows_options &>(window->machine().options()).d3d_snap_height(); + snap_width = downcast<windows_options &>(machine->options()).d3d_snap_width(); + snap_height = downcast<windows_options &>(machine->options()).d3d_snap_height(); prescale_force_x = 0; prescale_force_y = 0; - windows_options &winoptions = downcast<windows_options &>(window->machine().options()); + windows_options &winoptions = downcast<windows_options &>(machine->options()); options = (hlsl_options*)global_alloc_clear(hlsl_options); options->params_dirty = true; - strcpy(options->shadow_mask_texture, downcast<windows_options &>(window->machine().options()).screen_shadow_mask_texture()); // unsafe + strcpy(options->shadow_mask_texture, downcast<windows_options &>(machine->options()).screen_shadow_mask_texture()); // unsafe prescale_force_x = winoptions.d3d_hlsl_prescale_x(); prescale_force_y = winoptions.d3d_hlsl_prescale_y(); @@ -820,8 +811,6 @@ void shaders::init_fsfx_quad(void *vertbuf) if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - // get a pointer to the vertex buffer fsfx_vertices = (vertex *)vertbuf; if (fsfx_vertices == NULL) @@ -892,8 +881,6 @@ int shaders::create_resources(bool reset) if (!master_enable || !d3dintf->post_fx_available) return 0; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - HRESULT result = (*d3dintf->device.get_render_target)(d3d->get_device(), 0, &backbuffer); if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result); @@ -927,7 +914,7 @@ int shaders::create_resources(bool reset) } (*d3dintf->texture.get_surface_level)(avi_final_texture, 0, &avi_final_target); - emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ); + emu_file file(machine->options().art_path(), OPEN_FLAG_READ); render_load_png(shadow_bitmap, file, NULL, options->shadow_mask_texture); // experimental: if we have a shadow bitmap, create a texture for it @@ -943,11 +930,12 @@ int shaders::create_resources(bool reset) texture.set_palette(NULL); texture.seqid = 0; + // FIXME: should shadow bitmap really use prescale? // now create it - shadow_texture = new texture_info(d3d->get_texture_manager(), &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)); + shadow_texture = new texture_info(d3d->get_texture_manager(), &texture, video_config.prescale, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)); } - const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(); + const char *fx_dir = downcast<windows_options &>(machine->options()).screen_post_fx_dir(); default_effect = new effect(this, d3d->get_device(), "primary.fx", fx_dir); post_effect = new effect(this, d3d->get_device(), "post.fx", fx_dir); @@ -1066,8 +1054,6 @@ void shaders::begin_draw() if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - curr_effect = default_effect; default_effect->set_technique("TestTechnique"); @@ -1101,8 +1087,6 @@ void shaders::begin_frame() void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count, int dstw, int dsth) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, dst); if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); @@ -1146,8 +1130,6 @@ void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYP void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, dst); if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); result = (*d3dintf->device.clear)(d3d->get_device(), 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1,0,0,0), 0, 0); @@ -1231,7 +1213,6 @@ void shaders::init_effect_info(poly_info *poly) if (!master_enable || !d3dintf->post_fx_available) return; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); texture_info *texture = poly->get_texture(); if(PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && texture != NULL) @@ -1308,7 +1289,6 @@ cache_target* shaders::find_cache_target(UINT32 screen_index, int width, int hei void shaders::ntsc_pass(render_target *rt, vec2f &sourcedims, vec2f &delta) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; if(options->yiq_enable) @@ -1370,7 +1350,6 @@ void shaders::ntsc_pass(render_target *rt, vec2f &sourcedims, vec2f &delta) void shaders::color_convolution_pass(render_target *rt, vec2f &texsize, vec2f &sourcedims) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; curr_effect = color_effect; @@ -1398,7 +1377,6 @@ void shaders::color_convolution_pass(render_target *rt, vec2f &texsize, vec2f &s void shaders::prescale_pass(render_target *rt, vec2f &texsize, vec2f &sourcedims) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; curr_effect = prescale_effect; @@ -1426,7 +1404,6 @@ void shaders::prescale_pass(render_target *rt, vec2f &texsize, vec2f &sourcedims void shaders::deconverge_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; curr_effect = deconverge_effect; @@ -1454,7 +1431,6 @@ void shaders::deconverge_pass(render_target *rt, vec2f &texsize, vec2f &delta, v void shaders::defocus_pass(render_target *rt, vec2f &texsize) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; // Defocus pass 1 @@ -1503,7 +1479,6 @@ void shaders::defocus_pass(render_target *rt, vec2f &texsize) void shaders::phosphor_pass(render_target *rt, cache_target *ct, vec2f &texsize, bool focus_enable) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; curr_effect = phosphor_effect; @@ -1561,7 +1536,6 @@ void shaders::phosphor_pass(render_target *rt, cache_target *ct, vec2f &texsize, void shaders::avi_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims, poly_info *poly, int vertnum) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; curr_effect = post_effect; @@ -1616,7 +1590,6 @@ void shaders::avi_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec void shaders::screen_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims, poly_info *poly, int vertnum) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; curr_effect = post_effect; @@ -1650,7 +1623,6 @@ void shaders::screen_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, void shaders::raster_bloom_pass(render_target *rt, vec2f &texsize, vec2f &delta, poly_info *poly, int vertnum) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); UINT num_passes = 0; curr_effect = downsample_effect; @@ -1755,7 +1727,6 @@ void shaders::render_quad(poly_info *poly, int vertnum) return; UINT num_passes = 0; - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); curr_texture = poly->get_texture(); if(PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && curr_texture != NULL) @@ -2080,14 +2051,11 @@ render_target* shaders::get_vector_target() return NULL; } - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - return find_render_target(d3d->get_width(), d3d->get_height(), 0, 0); } void shaders::create_vector_target(render_primitive *prim) { - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); if (!add_render_target(d3d, NULL, d3d->get_width(), d3d->get_height(), 1, 1)) { vector_enable = false; @@ -2179,7 +2147,7 @@ bool shaders::add_render_target(renderer* d3d, texture_info* info, int width, in //============================================================ void shaders::enumerate_screens() { - screen_device_iterator iter(window->machine().root_device()); + screen_device_iterator iter(machine->root_device()); num_screens = iter.count(); } @@ -2202,8 +2170,6 @@ bool shaders::register_texture(texture_info *texture) enumerate_screens(); - renderer *d3d = dynamic_cast<renderer *>(window->m_renderer); - int hlsl_prescale_x = prescale_force_x; int hlsl_prescale_y = prescale_force_y; @@ -2935,7 +2901,7 @@ slider_state *shaders::init_slider_list() for (int index = 0; s_sliders[index].name != NULL; index++) { slider_desc *slider = &s_sliders[index]; - *tailptr = slider_alloc(window->machine(), slider->name, slider->minval, slider->defval, slider->maxval, slider->step, slider->adjustor, (void*)options); + *tailptr = slider_alloc(*machine, slider->name, slider->minval, slider->defval, slider->maxval, slider->step, slider->adjustor, (void*)options); tailptr = &(*tailptr)->next; } @@ -2994,8 +2960,9 @@ void uniform::update() } shaders *shadersys = m_shader->m_shaders; - renderer *d3d = dynamic_cast<renderer *>(shadersys->window->m_renderer); hlsl_options *options = shadersys->options; + renderer *d3d = shadersys->d3d; + switch(m_id) { diff --git a/src/osd/windows/d3dhlsl.h b/src/osd/windows/d3dhlsl.h index ac00d107f70..7f3a6bdf169 100644 --- a/src/osd/windows/d3dhlsl.h +++ b/src/osd/windows/d3dhlsl.h @@ -251,7 +251,7 @@ public: shaders(); ~shaders(); - void init(base *d3dintf, win_window_info *window); + void init(base *d3dintf, running_machine *machine, d3d::renderer *renderer); bool enabled() { return master_enable; } void toggle(); @@ -334,7 +334,9 @@ private: void raster_bloom_pass(render_target *rt, vec2f &texsize, vec2f &delta, poly_info *poly, int vertnum); base * d3dintf; // D3D interface - win_window_info * window; // D3D window info + + running_machine * machine; + d3d::renderer * d3d; // D3D renderer bool master_enable; // overall enable flag bool vector_enable; // vector post-processing enable flag diff --git a/src/osd/windows/drawbgfx.c b/src/osd/windows/drawbgfx.c index 6efde1b4014..b91703c2c3d 100644 --- a/src/osd/windows/drawbgfx.c +++ b/src/osd/windows/drawbgfx.c @@ -25,7 +25,7 @@ class renderer_bgfx : public osd_renderer { public: - renderer_bgfx(win_window_info *window) + renderer_bgfx(osd_window *window) : osd_renderer(window, FLAG_NONE) { } virtual ~renderer_bgfx() { } @@ -53,7 +53,7 @@ static void drawbgfx_exit(void); // drawnone_create //============================================================ -osd_renderer *drawbgfx_create(win_window_info *window) +osd_renderer *drawbgfx_create(osd_window *window) { return global_alloc(renderer_bgfx(window)); } diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index c03325fd604..659df1a1d30 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -257,7 +257,7 @@ render_primitive_list *d3d::renderer::get_primitives() // drawnone_create //============================================================ -static osd_renderer *drawd3d_create(win_window_info *window) +static osd_renderer *drawd3d_create(osd_window *window) { return global_alloc(d3d::renderer(window)); } @@ -504,7 +504,7 @@ void texture_manager::create_resources() texture.seqid = 0; // now create it - m_default_texture = global_alloc(texture_info(this, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32))); + m_default_texture = global_alloc(texture_info(this, &texture, m_renderer->window().prescale(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32))); } // experimental: if we have a vector bitmap, create a texture for it @@ -521,7 +521,7 @@ void texture_manager::create_resources() texture.seqid = 0; // now create it - m_vector_texture = global_alloc(texture_info(this, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32))); + m_vector_texture = global_alloc(texture_info(this, &texture, m_renderer->window().prescale(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32))); } } @@ -621,7 +621,7 @@ texture_info *texture_manager::find_texinfo(const render_texinfo *texinfo, UINT3 return NULL; } -renderer::renderer(win_window_info *window) +renderer::renderer(osd_window *window) : osd_renderer(window, FLAG_NONE) { m_device = NULL; @@ -644,7 +644,7 @@ int renderer::initialize() return false; // create the device immediately for the full screen case (defer for window mode) - if (window().fullscreen() && device_create()) + if (window().fullscreen() && device_create(window().m_focus_hwnd)) return false; return true; @@ -702,7 +702,7 @@ void texture_manager::update_textures() if (texture == NULL) { // if there isn't one, create a new texture - global_alloc(texture_info(this, &prim->texture, prim->flags)); + global_alloc(texture_info(this, &prim->texture, m_renderer->window().prescale(), prim->flags)); } else { @@ -810,7 +810,7 @@ void renderer::end_frame() // device_create //============================================================ -int renderer::device_create() +int renderer::device_create(HWND device_hwnd) { // if a device exists, free it if (m_device != NULL) @@ -876,7 +876,7 @@ try_again: D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; // create the D3D device - result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, window().m_focus_hwnd, + result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, device_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &m_presentation, &m_device); if (result != D3D_OK) { @@ -1065,12 +1065,12 @@ int renderer::device_verify_caps() m_shaders = global_alloc_clear(shaders); // FIXME: Dynamic cast - m_shaders->init(d3dintf, dynamic_cast<win_window_info *>(&window())); + m_shaders->init(d3dintf, &window().machine(), this); DWORD tempcaps; HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps); if (result != D3D_OK) osd_printf_verbose("Direct3D Error %08X during get_caps_dword call\n", (int)result); - if(tempcaps < 512) + if (tempcaps < 512) { osd_printf_verbose("Direct3D: Warning - Device does not support Pixel Shader 3.0, falling back to non-PS rendering\n"); d3dintf->post_fx_available = false; @@ -1403,7 +1403,7 @@ int renderer::update_window_size() // set the new bounds and create the device again m_width = rect_width(&client); m_height = rect_height(&client); - if (device_create()) + if (device_create(window().m_focus_hwnd)) return FALSE; // reset the resize state to normal, and indicate we made a change @@ -1916,7 +1916,7 @@ texture_info::~texture_info() // texture_info constructor //============================================================ -texture_info::texture_info(texture_manager *manager, const render_texinfo* texsource, UINT32 flags) +texture_info::texture_info(texture_manager *manager, const render_texinfo* texsource, int prescale, UINT32 flags) { HRESULT result; @@ -1926,8 +1926,8 @@ texture_info::texture_info(texture_manager *manager, const render_texinfo* texso m_hash = m_texture_manager->texture_compute_hash(texsource, flags); m_flags = flags; m_texinfo = *texsource; - m_xprescale = video_config.prescale; - m_yprescale = video_config.prescale; + m_xprescale = prescale; + m_yprescale = prescale; m_d3dtex = NULL; m_d3dsurface = NULL; @@ -1986,9 +1986,11 @@ texture_info::texture_info(texture_manager *manager, const render_texinfo* texso { m_yprescale--; } - if (m_xprescale != video_config.prescale || m_yprescale != video_config.prescale) + + int prescale = m_renderer->window().prescale(); + if (m_xprescale != prescale || m_yprescale != prescale) { - osd_printf_verbose("Direct3D: adjusting prescale from %dx%d to %dx%d\n", video_config.prescale, video_config.prescale, m_xprescale, m_yprescale); + osd_printf_verbose("Direct3D: adjusting prescale from %dx%d to %dx%d\n", prescale, prescale, m_xprescale, m_yprescale); } // loop until we allocate something or error @@ -2008,7 +2010,6 @@ texture_info::texture_info(texture_manager *manager, const render_texinfo* texso { m_d3dfinaltex = m_d3dtex; 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; diff --git a/src/osd/windows/drawd3d.h b/src/osd/windows/drawd3d.h index 94dccf5e190..a7f7d0ea5fc 100644 --- a/src/osd/windows/drawd3d.h +++ b/src/osd/windows/drawd3d.h @@ -99,7 +99,7 @@ class renderer : public osd_renderer { public: //renderer() { } - renderer(win_window_info *window); + renderer(osd_window *window); virtual ~renderer(); virtual int create(); @@ -112,7 +112,7 @@ public: int initialize(); - int device_create(); + int device_create(HWND device_HWND); int device_create_resources(); void device_delete(); void device_delete_resources(); diff --git a/src/osd/windows/drawdd.c b/src/osd/windows/drawdd.c index f5b85b56149..978c649295a 100644 --- a/src/osd/windows/drawdd.c +++ b/src/osd/windows/drawdd.c @@ -39,7 +39,7 @@ typedef HRESULT (WINAPI *directdrawenumerateex_ptr)(LPDDENUMCALLBACKEXA lpCallba class renderer_dd : public osd_renderer { public: - renderer_dd(win_window_info *window) + renderer_dd(osd_window *window) : osd_renderer(window, FLAG_NONE), //adapter(0), adapter_ptr(NULL), @@ -140,7 +140,8 @@ struct monitor_enum_info /* mode_enum_info holds information during a display mode enumeration */ struct mode_enum_info { - win_window_info * window; + renderer_dd * renderer; + osd_window * window; INT32 minimum_width, minimum_height; INT32 target_width, target_height; double target_refresh; @@ -191,7 +192,7 @@ static void drawdd_exit(void); // drawnone_create //============================================================ -static osd_renderer *drawdd_create(win_window_info *window) +static osd_renderer *drawdd_create(osd_window *window) { return global_alloc(renderer_dd(window)); } @@ -833,7 +834,7 @@ void renderer_dd::compute_blit_surface_size() // hardware stretch case: apply prescale if (video_config.hwstretch) { - int prescale = (video_config.prescale < 1) ? 1 : video_config.prescale; + int prescale = (window().prescale() < 1) ? 1 : window().prescale(); // clamp the prescale to something smaller than the target bounds xscale = prescale; @@ -1206,7 +1207,7 @@ static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) { float size_score, refresh_score, final_score; mode_enum_info *einfo = (mode_enum_info *)context; - renderer_dd *dd = dynamic_cast<renderer_dd *>(einfo->window->m_renderer); + renderer_dd *dd = einfo->renderer; // skip non-32 bit modes if (desc->ddpfPixelFormat.dwRGBBitCount != 32) @@ -1271,8 +1272,8 @@ void renderer_dd::pick_best_mode() window().target()->compute_minimum_size(einfo.minimum_width, einfo.minimum_height); // use those as the target for now - einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale); - einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale); + einfo.target_width = einfo.minimum_width * MAX(1, window().prescale()); + einfo.target_height = einfo.minimum_height * MAX(1, window().prescale()); // determine the refresh rate of the primary screen einfo.target_refresh = 60.0; @@ -1289,14 +1290,15 @@ void renderer_dd::pick_best_mode() } // if we are stretching, aim for a mode approximately 2x the game's resolution - else if (video_config.prescale <= 1) + else if (window().prescale() <= 1) { einfo.target_width *= 2; einfo.target_height *= 2; } // fill in the rest of the data - einfo.window = dynamic_cast<win_window_info *>(&window()); + einfo.window = &window(); + einfo.renderer = this; einfo.best_score = 0.0f; // enumerate the modes diff --git a/src/osd/windows/drawgdi.c b/src/osd/windows/drawgdi.c index ff643ce6a41..a770075e32f 100644 --- a/src/osd/windows/drawgdi.c +++ b/src/osd/windows/drawgdi.c @@ -25,7 +25,7 @@ class renderer_gdi : public osd_renderer { public: - renderer_gdi(win_window_info *window) + renderer_gdi(osd_window *window) : osd_renderer(window, FLAG_NONE), bmdata(NULL), bmsize(0) { } virtual ~renderer_gdi() { } @@ -57,7 +57,7 @@ static void drawgdi_exit(void); // drawnone_create //============================================================ -static osd_renderer *drawgdi_create(win_window_info *window) +static osd_renderer *drawgdi_create(osd_window *window) { return global_alloc(renderer_gdi(window)); } diff --git a/src/osd/windows/drawnone.c b/src/osd/windows/drawnone.c index 87c7a9fb0b2..82a4f12c80b 100644 --- a/src/osd/windows/drawnone.c +++ b/src/osd/windows/drawnone.c @@ -20,7 +20,7 @@ class renderer_none : public osd_renderer { public: - renderer_none(win_window_info *window) + renderer_none(osd_window *window) : osd_renderer(window, FLAG_NONE) { } virtual ~renderer_none() { } @@ -47,7 +47,7 @@ static void drawnone_exit(void); // drawnone_create //============================================================ -osd_renderer *drawnone_create(win_window_info *window) +osd_renderer *drawnone_create(osd_window *window) { return global_alloc(renderer_none(window)); } diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 9c0d42ea6d4..1bc96821403 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -297,7 +297,7 @@ void windows_osd_interface::window_exit() win_window_info::win_window_info(running_machine &machine) - : m_next(NULL), + : osd_window(), m_next(NULL), m_init_state(0), m_startmaximized(0), m_isminimized(0), @@ -320,6 +320,7 @@ win_window_info::win_window_info(running_machine &machine) m_non_fullscreen_bounds.top = 0; m_non_fullscreen_bounds.right = 0; m_non_fullscreen_bounds.bottom = 0; + m_prescale = video_config.prescale; } win_window_info::~win_window_info() diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index fd968a18739..9cdec018420 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -32,6 +32,14 @@ // TYPE DEFINITIONS //============================================================ +/* ------------------------------------------------------ + * + * All types named osd_* will ultimately be located in + * the modules tree. They are temporarily maintained in + * window.h until basic code simplification is finished. + * + */ + class win_window_info; class osd_window @@ -46,6 +54,7 @@ public: m_maxwidth(0), m_maxheight(0), m_refresh(0), #endif + m_prescale(1), m_primlist(NULL) {} virtual ~osd_window() { } @@ -54,12 +63,12 @@ public: virtual int fullscreen() const = 0; virtual running_machine &machine() const = 0; + int prescale() const { return m_prescale; }; + #ifdef OSD_SDL virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0; virtual sdl_monitor_info *monitor() const = 0; virtual void get_size(int &w, int &h) = 0; - virtual int index() const = 0; - virtual int prescale() const = 0; #if (SDLMAME_SDL2) virtual SDL_Window *sdl_window() = 0; #else @@ -74,6 +83,8 @@ public: // window handle and info HWND m_hwnd; + // FIXME: this is the same as win_window_list->m_hwnd, i.e. first window. + // During modularization, this should be passed in differently HWND m_focus_hwnd; // monitor info @@ -83,8 +94,8 @@ public: int m_refresh; #endif + int m_prescale; render_primitive_list * m_primlist; - }; class osd_renderer @@ -94,6 +105,7 @@ public: /* Generic flags */ static const int FLAG_NONE = 0x0000; static const int FLAG_NEEDS_OPENGL = 0x0001; + static const int FLAG_HAS_VECTOR_SCREEN = 0x0002; /* SDL 1.2 flags */ static const int FLAG_NEEDS_DOUBLEBUF = 0x0100; @@ -105,8 +117,10 @@ public: virtual ~osd_renderer() { } osd_window &window() { return *m_window; } - int flags() const { return m_flags; } bool has_flags(const int flag) { return ((m_flags & flag)) == flag; } + void set_flags(int aflag) { m_flags |= aflag; } + void clear_flags(int aflag) { m_flags &= ~aflag; } + void notify_changed() { set_flags(FI_CHANGED); } @@ -131,9 +145,6 @@ protected: /* Internal flags */ static const int FI_CHANGED = 0x010000; - void set_flags(int aflag) { m_flags |= aflag; } - void clear_flags(int aflag) { m_flags &= ~aflag; } - private: osd_window *m_window; @@ -196,7 +207,7 @@ private: struct osd_draw_callbacks { - osd_renderer *(*create)(win_window_info *window); + osd_renderer *(*create)(osd_window *window); void (*exit)(void); }; |