Previous 199869 Revisions Next

r34976 Wednesday 11th February, 2015 at 18:59:43 UTC by Couriersud
More osd_window migration. (nw)
[src/osd/sdl]draw13.c drawogl.c drawsdl.c window.c window.h
[src/osd/windows]d3dcomm.h d3dhlsl.c d3dhlsl.h drawbgfx.c drawd3d.c drawd3d.h drawdd.c drawgdi.c drawnone.c window.c window.h

trunk/src/osd/sdl/draw13.c
r243487r243488
6868    : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0),
6969      rotwidth(0), rotheight(0)
7070    {}
71    void compute(const render_primitive &prim);
71    void compute(const render_primitive &prim, const int prescale);
7272
7373   INT32           dudx, dvdx, dudy, dvdy;
7474   INT32           startu, startv;
r243487r243488
142142class sdl_info13 : public osd_renderer
143143{
144144public:
145    sdl_info13(sdl_window_info *w)
145    sdl_info13(osd_window *w)
146146    : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_renderer(NULL),
147147      m_last_hofs(0), m_last_vofs(0),
148148      m_width(0), m_height(0),
r243487r243488
501501   }
502502}
503503
504static osd_renderer *drawsdl2_create(sdl_window_info *window)
504static osd_renderer *drawsdl2_create(osd_window *window)
505505{
506506   return global_alloc(sdl_info13(window));
507507}
r243487r243488
988988//  compute rotation setup
989989//============================================================
990990
991void quad_setup_data::compute(const render_primitive &prim)
991void quad_setup_data::compute(const render_primitive &prim, const int prescale)
992992{
993993   const render_quad_texuv *texcoords = &prim.texcoords;
994994   int texwidth = prim.texture.width;
r243487r243488
998998   float fscale;
999999   /* determine U/V deltas */
10001000   if ((PRIMFLAG_GET_SCREENTEX(prim.flags)))
1001      fscale = (float) video_config.prescale;
1001      fscale = (float) prescale;
10021002   else
10031003      fscale = 1.0f;
10041004
r243487r243488
10811081   quad_setup_data setup;
10821082   texture_info *texture;
10831083
1084   setup.compute(prim);
1084   setup.compute(prim, window().prescale());
10851085
10861086   texture = texture_find(prim, setup);
10871087
trunk/src/osd/sdl/drawogl.c
r243487r243488
221221class sdl_info_ogl : public osd_renderer
222222{
223223public:
224   sdl_info_ogl(sdl_window_info *window)
224   sdl_info_ogl(osd_window *window)
225225   : osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0),
226      m_screen_width(0), m_screen_height(0),
227226      m_width(0), m_height(0),
228227      m_blitwidth(0), m_blitheight(0),
229228#if (SDLMAME_SDL2)
r243487r243488
292291   void texture_all_disable();
293292
294293   INT32           m_blittimer;
295   int             m_screen_width;
296   int             m_screen_height;
297294   int            m_width;
298295   int            m_height;
299296   int            m_blitwidth;
r243487r243488
462459//  drawsdl_init
463460//============================================================
464461
465static osd_renderer *drawogl_create(sdl_window_info *window)
462static osd_renderer *drawogl_create(osd_window *window)
466463{
467464   return global_alloc(sdl_info_ogl(window));
468465}
r243487r243488
745742#else
746743#endif
747744
748   m_screen_width = 0;
749   m_screen_height = 0;
750
751745   m_blittimer = 0;
752746   m_surf_w = 0;
753747   m_surf_h = 0;
r243487r243488
12101204   render_primitive *prim;
12111205   texture_info *texture=NULL;
12121206   float vofs, hofs;
1213   int  pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE, scrnum, is_vector;
1214   const screen_device *screen;
1207   int  pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE;
12151208   int width = 0; int height = 0;
12161209
12171210   if (video_config.novideo)
r243487r243488
12331226
12341227#if (SDLMAME_SDL2)
12351228   SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
1236#else
1237   if (!m_init_context)
1238   {
1239      screen_device_iterator myiter(window().machine().root_device());
1240      for (screen = myiter.first(); screen != NULL; screen = myiter.next())
1241      {
1242         if (window().index() == 0)
1243         {
1244            if ((screen->width() != m_screen_width) || (screen->height() != m_screen_height))
1245            {
1246               m_screen_width = screen->width();
1247               m_screen_height = screen->height();
1248
1249               // force all textures to be regenerated
1250               destroy_all_textures();
1251            }
1252            break;
1253         }
1254      }
1255   }
12561229#endif
12571230
12581231   if (m_init_context)
r243487r243488
12711244      glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
12721245   }
12731246
1274   // figure out if we're vector
1275   scrnum = is_vector = 0;
1276   screen_device_iterator iter(window().machine().root_device());
1277   for (screen = iter.first(); screen != NULL; screen = iter.next())
1278   {
1279      if (scrnum == window().index())
1280      {
1281         is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0;
1282         break;
1283      }
1284      else
1285      {
1286         scrnum++;
1287      }
1288   }
1289
12901247   // only clear if the geometry changes (and for 2 frames afterward to clear double and triple buffers)
1291   if ((m_blittimer > 0) || (is_vector))
1248   if ((m_blittimer > 0) || has_flags(FLAG_HAS_VECTOR_SCREEN))
12921249   {
12931250      glClear(GL_COLOR_BUFFER_BIT);
12941251      m_blittimer--;
r243487r243488
13041261         loadGLExtensions();
13051262      }
13061263
1264#if (!SDLMAME_SDL2)
1265      // force all textures to be regenerated
1266      destroy_all_textures();
1267#endif
1268
13071269      m_surf_w = m_width;
13081270      m_surf_h = m_height;
13091271
trunk/src/osd/sdl/drawsdl.c
r243487r243488
5050{
5151public:
5252
53   sdl_info(sdl_window_info *w, int extra_flags)
53   sdl_info(osd_window *w, int extra_flags)
5454   : osd_renderer(w, extra_flags),
5555   #if (SDLMAME_SDL2)
5656   m_sdl_renderer(NULL),
r243487r243488
227227}
228228
229229
230static osd_renderer *drawsdl_create(sdl_window_info *window)
230static osd_renderer *drawsdl_create(osd_window *window)
231231{
232232   // FIXME: QUALITY HINTS
233233#if (SDLMAME_SDL2)
r243487r243488
292292      int m_hw_scale_height = 0;
293293
294294      window().target()->compute_minimum_size(m_hw_scale_width, m_hw_scale_height);
295      if (video_config.prescale)
295      if (window().prescale())
296296      {
297         m_hw_scale_width *= video_config.prescale;
298         m_hw_scale_height *= video_config.prescale;
297         m_hw_scale_width *= window().prescale();
298         m_hw_scale_height *= window().prescale();
299299
300300         /* This must be a multiple of 2 */
301301         m_hw_scale_width = (m_hw_scale_width + 1) & ~1;
r243487r243488
329329
330330   window().target()->compute_minimum_size(minimum_width, minimum_height);
331331
332   if (video_config.prescale)
332   if (window().prescale())
333333   {
334      minimum_width *= video_config.prescale;
335      minimum_height *= video_config.prescale;
334      minimum_width *= window().prescale();
335      minimum_height *= window().prescale();
336336   }
337337
338338   if (m_yuvsurf != NULL)
trunk/src/osd/sdl/window.c
r243487r243488
10171017   // if we're visible and running and not in the middle of a resize, draw
10181018   if (m_target != NULL)
10191019   {
1020
1021
1022
10201023      int tempwidth, tempheight;
10211024
10221025      // see if the games video mode has changed
r243487r243488
13271330   // Some configurations require events to be polled in the worker thread
13281331   sdlinput_process_events_buf();
13291332
1333   // Check whether window has vector screens
1334
1335   {
1336#if 1
1337      int scrnum = 0;
1338      int is_vector = 0;
1339      screen_device_iterator iter(window->machine().root_device());
1340      for (const screen_device *screen = iter.first(); screen != NULL; screen = iter.next())
1341      {
1342         if (scrnum == window->m_index)
1343         {
1344            is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0;
1345            break;
1346         }
1347         else
1348         {
1349            scrnum++;
1350         }
1351      }
1352      if (is_vector)
1353         window->renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN);
1354      else
1355         window->renderer().clear_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN);
1356#endif
1357   }
1358
1359
13301360   window->m_primlist = wp->list();
13311361
13321362   // if no bitmap, just fill
trunk/src/osd/sdl/window.h
r243487r243488
3636{
3737public:
3838   osd_window()
39   :      m_primlist(NULL),
40      m_start_viewscreen(0)
39   :
40#ifdef OSD_SDL
41      m_start_viewscreen(0),
42#else
43      m_hwnd(0), m_focus_hwnd(0), m_monitor(NULL), m_resize_state(0),
44      m_maxwidth(0), m_maxheight(0),
45      m_refresh(0),
46#endif
47      m_prescale(1),
48      m_primlist(NULL)
4149       {}
4250   virtual ~osd_window() { }
51
52   virtual render_target *target() = 0;
53   virtual int fullscreen() const = 0;
54   virtual running_machine &machine() const = 0;
55
56   int prescale() const { return m_prescale; };
57
4358#ifdef OSD_SDL
4459   virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
4560   virtual sdl_monitor_info *monitor() const = 0;
46   virtual render_target *target() = 0;
4761   virtual void get_size(int &w, int &h) = 0;
48   virtual int fullscreen() const = 0;
49   virtual int index() const = 0;
50   virtual int prescale() const = 0;
5162#if (SDLMAME_SDL2)
5263   virtual SDL_Window *sdl_window() = 0;
5364#else
5465   virtual SDL_Surface *sdl_surface() = 0;
5566#endif
5667
57   virtual running_machine &machine() const = 0;
68   in                  m_start_viewscreen;
5869
59   render_primitive_list *m_primlist;
60   int                 m_start_viewscreen;
70#else
71   virtual bool win_has_menu() = 0;
72   virtual win_monitor_info *winwindow_video_window_monitor(const RECT *proposed) = 0;
6173
74   // window handle and info
75   HWND               m_hwnd;
76   HWND                   m_focus_hwnd;
77
78   // monitor info
79   win_monitor_info *     m_monitor;
80   int                    m_resize_state;
81   int                    m_maxwidth, m_maxheight;
82   int                    m_refresh;
6283#endif
84
85   int                  m_prescale;
86   render_primitive_list    *m_primlist;
6387};
6488
6589class osd_renderer
r243487r243488
6993   /* Generic flags */
7094   static const int FLAG_NONE                = 0x0000;
7195   static const int FLAG_NEEDS_OPENGL          = 0x0001;
96   static const int FLAG_HAS_VECTOR_SCREEN      = 0x0002;
7297
7398#if (!(SDLMAME_SDL2))
7499   /* SDL 1.2 flags */
r243487r243488
82107   virtual ~osd_renderer() { }
83108
84109   osd_window &window() { return *m_window; }
85   int flags() const { return m_flags; }
86110   bool has_flags(const int flag) { return ((m_flags & flag)) == flag; }
111   void set_flags(int aflag) { m_flags |= aflag; }
112   void clear_flags(int aflag) { m_flags &= ~aflag; }
87113
114
88115   void notify_changed() { set_flags(FI_CHANGED); }
89116
90117   /* Interface to be implemented by render code */
r243487r243488
108135   /* Internal flags */
109136   static const int FI_CHANGED                = 0x010000;
110137
111   void set_flags(int aflag) { m_flags |= aflag; }
112   void clear_flags(int aflag) { m_flags &= ~aflag; }
113
114138private:
115139
116140   osd_window      *m_window;
r243487r243488
185209   sdl_monitor_info *monitor() const { return m_monitor; }
186210   int fullscreen() const { return m_fullscreen; }
187211
188   int index() const { return m_index; }
189
190212   render_target *target() { return m_target; }
191213#if (SDLMAME_SDL2)
192214   SDL_Window *sdl_window() { return m_sdl_window; }
r243487r243488
224246   osd_event *         m_rendered_event;
225247   render_target *     m_target;
226248
227   int                 m_prescale;
228
229249#if (SDLMAME_SDL2)
230250   // Needs to be here as well so we can identify window
231251   SDL_Window          *m_sdl_window;
r243487r243488
278298
279299struct osd_draw_callbacks
280300{
281   osd_renderer *(*create)(sdl_window_info *window);
301   osd_renderer *(*create)(osd_window *window);
282302   void (*exit)(void);
283303};
284304
trunk/src/osd/windows/d3dcomm.h
r243487r243488
108108class texture_info
109109{
110110public:
111   texture_info(texture_manager *manager, const render_texinfo *texsource, UINT32 flags);
111   texture_info(texture_manager *manager, const render_texinfo *texsource, int prescale, UINT32 flags);
112112   ~texture_info();
113113
114114   render_texinfo &        get_texinfo() { return m_texinfo; }
trunk/src/osd/windows/d3dhlsl.c
r243487r243488
224224   if (!master_enable || !d3dintf->post_fx_available)
225225      return;
226226
227   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
228
229227   HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), snap_width, snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &snap_copy_texture);
230228   if (result != D3D_OK)
231229   {
r243487r243488
257255   if (!master_enable || !d3dintf->post_fx_available)
258256      return;
259257
260   windows_options &options = downcast<windows_options &>(window->machine().options());
258   windows_options &options = downcast<windows_options &>(machine->options());
261259   const char *filename = options.d3d_hlsl_write();
262260
263261   if (avi_output_file != NULL)
r243487r243488
276274   if (!master_enable || !d3dintf->post_fx_available)
277275      return;
278276
279   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
280
281277   D3DLOCKED_RECT rect;
282278
283279   // if we don't have a bitmap, or if it's not the right size, allocate a new one
r243487r243488
326322   if (!master_enable || !d3dintf->post_fx_available)
327323      return;
328324
329   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
330
331325   D3DLOCKED_RECT rect;
332326
333327   render_snap = false;
r243487r243488
370364
371365         int idx = cy * 2 + cx;
372366
373         emu_file file(window->machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
367         emu_file file(machine->options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
374368         file_error filerr = open_next(d3d, file, NULL, "png", idx);
375369         if (filerr != FILERR_NONE)
376370            return;
377371
378372         // add two text entries describing the image
379373         astring text1(emulator_info::get_appname(), " ", build_version);
380         astring text2(window->machine().system().manufacturer, " ", window->machine().system().description);
374         astring text2(machine->system().manufacturer, " ", machine->system().description);
381375         png_info pnginfo = { 0 };
382376         png_add_text(&pnginfo, "Software", text1);
383377         png_add_text(&pnginfo, "System", text2);
r243487r243488
438432      return;
439433
440434   // get the current time
441   attotime curtime = window->machine().time();
435   attotime curtime = machine->time();
442436
443437   avi_update_snap(surface);
444438
r243487r243488
519513   if (!master_enable || !d3dintf->post_fx_available)
520514      return;
521515
522   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
523
524516   // stop any existing recording
525517   end_avi_recording();
526518
527519   // reset the state
528520   avi_frame = 0;
529   avi_next_frame_time = window->machine().time();
521   avi_next_frame_time = machine->time();
530522
531523   // build up information about this new movie
532524   avi_movie_info info;
533525   info.video_format = 0;
534   info.video_timescale = 1000 * ((window->machine().first_screen() != NULL) ? ATTOSECONDS_TO_HZ(window->machine().first_screen()->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE);
526   info.video_timescale = 1000 * ((machine->first_screen() != NULL) ? ATTOSECONDS_TO_HZ(machine->first_screen()->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE);
535527   info.video_sampletime = 1000;
536528   info.video_numsamples = 0;
537529   info.video_width = snap_width;
r243487r243488
539531   info.video_depth = 24;
540532
541533   info.audio_format = 0;
542   info.audio_timescale = window->machine().sample_rate();
534   info.audio_timescale = machine->sample_rate();
543535   info.audio_sampletime = 1;
544536   info.audio_numsamples = 0;
545537   info.audio_channels = 2;
546538   info.audio_samplebits = 16;
547   info.audio_samplerate = window->machine().sample_rate();
539   info.audio_samplerate = machine->sample_rate();
548540
549541   // create a new temporary movie file
550542   file_error filerr;
551543   astring fullpath;
552544   {
553      emu_file tempfile(window->machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
545      emu_file tempfile(machine->options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
554546      if (name != NULL)
555547      {
556548         filerr = tempfile.open(name);
r243487r243488
678670   if (!master_enable || !d3dintf->post_fx_available)
679671      return;
680672
681   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
682
683673   if(texture != NULL)
684674   {
685675      paused = texture->paused();
r243487r243488
699689//  shaders::init
700690//============================================================
701691
702void shaders::init(base *d3dintf, win_window_info *window)
692void shaders::init(base *d3dintf, running_machine *machine, d3d::renderer *renderer)
703693{
704694   if (!d3dintf->post_fx_available)
705695      return;
r243487r243488
713703   }
714704
715705   this->d3dintf = d3dintf;
716   this->window = window;
706   this->machine = machine;
707   this->d3d = renderer;
717708
718   master_enable = downcast<windows_options &>(window->machine().options()).d3d_hlsl_enable();
709   master_enable = downcast<windows_options &>(machine->options()).d3d_hlsl_enable();
719710   prescale_size_x = 1;
720711   prescale_size_y = 1;
721   preset = downcast<windows_options &>(window->machine().options()).d3d_hlsl_preset();
712   preset = downcast<windows_options &>(machine->options()).d3d_hlsl_preset();
722713   if (preset < -1 || preset > 3)
723714   {
724715      preset = -1;
725716   }
726717
727   snap_width = downcast<windows_options &>(window->machine().options()).d3d_snap_width();
728   snap_height = downcast<windows_options &>(window->machine().options()).d3d_snap_height();
718   snap_width = downcast<windows_options &>(machine->options()).d3d_snap_width();
719   snap_height = downcast<windows_options &>(machine->options()).d3d_snap_height();
729720   prescale_force_x = 0;
730721   prescale_force_y = 0;
731722
732   windows_options &winoptions = downcast<windows_options &>(window->machine().options());
723   windows_options &winoptions = downcast<windows_options &>(machine->options());
733724
734725   options = (hlsl_options*)global_alloc_clear(hlsl_options);
735726
736727   options->params_dirty = true;
737   strcpy(options->shadow_mask_texture, downcast<windows_options &>(window->machine().options()).screen_shadow_mask_texture()); // unsafe
728   strcpy(options->shadow_mask_texture, downcast<windows_options &>(machine->options()).screen_shadow_mask_texture()); // unsafe
738729
739730   prescale_force_x = winoptions.d3d_hlsl_prescale_x();
740731   prescale_force_y = winoptions.d3d_hlsl_prescale_y();
r243487r243488
820811   if (!master_enable || !d3dintf->post_fx_available)
821812      return;
822813
823   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
824
825814   // get a pointer to the vertex buffer
826815   fsfx_vertices = (vertex *)vertbuf;
827816   if (fsfx_vertices == NULL)
r243487r243488
892881   if (!master_enable || !d3dintf->post_fx_available)
893882      return 0;
894883
895   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
896
897884   HRESULT result = (*d3dintf->device.get_render_target)(d3d->get_device(), 0, &backbuffer);
898885   if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
899886
r243487r243488
927914   }
928915   (*d3dintf->texture.get_surface_level)(avi_final_texture, 0, &avi_final_target);
929916
930   emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ);
917   emu_file file(machine->options().art_path(), OPEN_FLAG_READ);
931918   render_load_png(shadow_bitmap, file, NULL, options->shadow_mask_texture);
932919
933920   // experimental: if we have a shadow bitmap, create a texture for it
r243487r243488
943930      texture.set_palette(NULL);
944931      texture.seqid = 0;
945932
933      // FIXME: should shadow bitmap really use prescale?
946934      // now create it
947      shadow_texture = new texture_info(d3d->get_texture_manager(), &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
935      shadow_texture = new texture_info(d3d->get_texture_manager(), &texture, video_config.prescale, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
948936   }
949937
950   const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir();
938   const char *fx_dir = downcast<windows_options &>(machine->options()).screen_post_fx_dir();
951939
952940   default_effect = new effect(this, d3d->get_device(), "primary.fx", fx_dir);
953941   post_effect = new effect(this, d3d->get_device(), "post.fx", fx_dir);
r243487r243488
10661054   if (!master_enable || !d3dintf->post_fx_available)
10671055      return;
10681056
1069   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
1070
10711057   curr_effect = default_effect;
10721058
10731059   default_effect->set_technique("TestTechnique");
r243487r243488
11011087void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYPE prim_type,
11021088                  UINT32 prim_index, UINT32 prim_count, int dstw, int dsth)
11031089{
1104   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
1105
11061090   HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, dst);
11071091   if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
11081092
r243487r243488
11461130void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYPE prim_type,
11471131                  UINT32 prim_index, UINT32 prim_count)
11481132{
1149   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
1150
11511133   HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, dst);
11521134   if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
11531135   result = (*d3dintf->device.clear)(d3d->get_device(), 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1,0,0,0), 0, 0);
r243487r243488
12311213   if (!master_enable || !d3dintf->post_fx_available)
12321214      return;
12331215
1234   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
12351216   texture_info *texture = poly->get_texture();
12361217
12371218   if(PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && texture != NULL)
r243487r243488
13081289
13091290void shaders::ntsc_pass(render_target *rt, vec2f &sourcedims, vec2f &delta)
13101291{
1311   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
13121292   UINT num_passes = 0;
13131293
13141294   if(options->yiq_enable)
r243487r243488
13701350
13711351void shaders::color_convolution_pass(render_target *rt, vec2f &texsize, vec2f &sourcedims)
13721352{
1373   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
13741353   UINT num_passes = 0;
13751354
13761355   curr_effect = color_effect;
r243487r243488
13981377
13991378void shaders::prescale_pass(render_target *rt, vec2f &texsize, vec2f &sourcedims)
14001379{
1401   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
14021380   UINT num_passes = 0;
14031381
14041382   curr_effect = prescale_effect;
r243487r243488
14261404
14271405void shaders::deconverge_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims)
14281406{
1429   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
14301407   UINT num_passes = 0;
14311408
14321409   curr_effect = deconverge_effect;
r243487r243488
14541431
14551432void shaders::defocus_pass(render_target *rt, vec2f &texsize)
14561433{
1457   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
14581434   UINT num_passes = 0;
14591435
14601436   // Defocus pass 1
r243487r243488
15031479
15041480void shaders::phosphor_pass(render_target *rt, cache_target *ct, vec2f &texsize, bool focus_enable)
15051481{
1506   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
15071482   UINT num_passes = 0;
15081483
15091484   curr_effect = phosphor_effect;
r243487r243488
15611536
15621537void shaders::avi_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims, poly_info *poly, int vertnum)
15631538{
1564   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
15651539   UINT num_passes = 0;
15661540
15671541   curr_effect = post_effect;
r243487r243488
16161590
16171591void shaders::screen_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims, poly_info *poly, int vertnum)
16181592{
1619   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
16201593   UINT num_passes = 0;
16211594
16221595   curr_effect = post_effect;
r243487r243488
16501623
16511624void shaders::raster_bloom_pass(render_target *rt, vec2f &texsize, vec2f &delta, poly_info *poly, int vertnum)
16521625{
1653   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
16541626   UINT num_passes = 0;
16551627
16561628   curr_effect = downsample_effect;
r243487r243488
17551727      return;
17561728
17571729   UINT num_passes = 0;
1758   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
17591730   curr_texture = poly->get_texture();
17601731
17611732   if(PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && curr_texture != NULL)
r243487r243488
20802051      return NULL;
20812052   }
20822053
2083   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
2084
20852054   return find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
20862055}
20872056
20882057void shaders::create_vector_target(render_primitive *prim)
20892058{
2090   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
20912059   if (!add_render_target(d3d, NULL, d3d->get_width(), d3d->get_height(), 1, 1))
20922060   {
20932061      vector_enable = false;
r243487r243488
21792147//============================================================
21802148void shaders::enumerate_screens()
21812149{
2182   screen_device_iterator iter(window->machine().root_device());
2150   screen_device_iterator iter(machine->root_device());
21832151   num_screens = iter.count();
21842152}
21852153
r243487r243488
22022170
22032171   enumerate_screens();
22042172
2205   renderer *d3d = dynamic_cast<renderer *>(window->m_renderer);
2206
22072173   int hlsl_prescale_x = prescale_force_x;
22082174   int hlsl_prescale_y = prescale_force_y;
22092175
r243487r243488
29352901   for (int index = 0; s_sliders[index].name != NULL; index++)
29362902   {
29372903      slider_desc *slider = &s_sliders[index];
2938      *tailptr = slider_alloc(window->machine(), slider->name, slider->minval, slider->defval, slider->maxval, slider->step, slider->adjustor, (void*)options);
2904      *tailptr = slider_alloc(*machine, slider->name, slider->minval, slider->defval, slider->maxval, slider->step, slider->adjustor, (void*)options);
29392905      tailptr = &(*tailptr)->next;
29402906   }
29412907
r243487r243488
29942960   }
29952961
29962962   shaders *shadersys = m_shader->m_shaders;
2997   renderer *d3d = dynamic_cast<renderer *>(shadersys->window->m_renderer);
29982963   hlsl_options *options = shadersys->options;
2964   renderer *d3d = shadersys->d3d;
29992965
2966
30002967   switch(m_id)
30012968   {
30022969      case CU_SCREEN_DIMS:
trunk/src/osd/windows/d3dhlsl.h
r243487r243488
251251   shaders();
252252   ~shaders();
253253
254   void init(base *d3dintf, win_window_info *window);
254   void init(base *d3dintf, running_machine *machine, d3d::renderer *renderer);
255255
256256   bool enabled() { return master_enable; }
257257   void toggle();
r243487r243488
334334   void                    raster_bloom_pass(render_target *rt, vec2f &texsize, vec2f &delta, poly_info *poly, int vertnum);
335335
336336   base *                  d3dintf;                    // D3D interface
337   win_window_info *       window;                     // D3D window info
338337
338   running_machine *       machine;
339   d3d::renderer *         d3d;                  // D3D renderer
340
339341   bool                    master_enable;              // overall enable flag
340342   bool                    vector_enable;              // vector post-processing enable flag
341343   bool                    paused;                     // whether or not rendering is currently paused
trunk/src/osd/windows/drawbgfx.c
r243487r243488
2525class renderer_bgfx : public osd_renderer
2626{
2727public:
28   renderer_bgfx(win_window_info *window)
28   renderer_bgfx(osd_window *window)
2929   : osd_renderer(window, FLAG_NONE) { }
3030
3131   virtual ~renderer_bgfx() { }
r243487r243488
5353//  drawnone_create
5454//============================================================
5555
56osd_renderer *drawbgfx_create(win_window_info *window)
56osd_renderer *drawbgfx_create(osd_window *window)
5757{
5858   return global_alloc(renderer_bgfx(window));
5959}
trunk/src/osd/windows/drawd3d.c
r243487r243488
257257//  drawnone_create
258258//============================================================
259259
260static osd_renderer *drawd3d_create(win_window_info *window)
260static osd_renderer *drawd3d_create(osd_window *window)
261261{
262262   return global_alloc(d3d::renderer(window));
263263}
r243487r243488
504504      texture.seqid = 0;
505505
506506      // now create it
507      m_default_texture = global_alloc(texture_info(this, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)));
507      m_default_texture = global_alloc(texture_info(this, &texture, m_renderer->window().prescale(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)));
508508   }
509509
510510   // experimental: if we have a vector bitmap, create a texture for it
r243487r243488
521521      texture.seqid = 0;
522522
523523      // now create it
524      m_vector_texture = global_alloc(texture_info(this, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)));
524      m_vector_texture = global_alloc(texture_info(this, &texture, m_renderer->window().prescale(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)));
525525   }
526526}
527527
r243487r243488
621621   return NULL;
622622}
623623
624renderer::renderer(win_window_info *window)
624renderer::renderer(osd_window *window)
625625   : osd_renderer(window, FLAG_NONE)
626626{
627627   m_device = NULL;
r243487r243488
644644      return false;
645645
646646   // create the device immediately for the full screen case (defer for window mode)
647   if (window().fullscreen() && device_create())
647   if (window().fullscreen() && device_create(window().m_focus_hwnd))
648648      return false;
649649
650650   return true;
r243487r243488
702702         if (texture == NULL)
703703         {
704704            // if there isn't one, create a new texture
705            global_alloc(texture_info(this, &prim->texture, prim->flags));
705            global_alloc(texture_info(this, &prim->texture, m_renderer->window().prescale(), prim->flags));
706706         }
707707         else
708708         {
r243487r243488
810810//  device_create
811811//============================================================
812812
813int renderer::device_create()
813int renderer::device_create(HWND device_hwnd)
814814{
815815   // if a device exists, free it
816816   if (m_device != NULL)
r243487r243488
876876                                       D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
877877
878878   // create the D3D device
879   result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, window().m_focus_hwnd,
879   result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, device_hwnd,
880880               D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &m_presentation, &m_device);
881881   if (result != D3D_OK)
882882   {
r243487r243488
10651065
10661066   m_shaders = global_alloc_clear(shaders);
10671067   // FIXME: Dynamic cast
1068   m_shaders->init(d3dintf, dynamic_cast<win_window_info *>(&window()));
1068   m_shaders->init(d3dintf, &window().machine(), this);
10691069
10701070   DWORD tempcaps;
10711071   HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps);
10721072   if (result != D3D_OK) osd_printf_verbose("Direct3D Error %08X during get_caps_dword call\n", (int)result);
1073   if(tempcaps < 512)
1073   if (tempcaps < 512)
10741074   {
10751075      osd_printf_verbose("Direct3D: Warning - Device does not support Pixel Shader 3.0, falling back to non-PS rendering\n");
10761076      d3dintf->post_fx_available = false;
r243487r243488
14031403   // set the new bounds and create the device again
14041404   m_width = rect_width(&client);
14051405   m_height = rect_height(&client);
1406   if (device_create())
1406   if (device_create(window().m_focus_hwnd))
14071407      return FALSE;
14081408
14091409   // reset the resize state to normal, and indicate we made a change
r243487r243488
19161916//  texture_info constructor
19171917//============================================================
19181918
1919texture_info::texture_info(texture_manager *manager, const render_texinfo* texsource, UINT32 flags)
1919texture_info::texture_info(texture_manager *manager, const render_texinfo* texsource, int prescale, UINT32 flags)
19201920{
19211921   HRESULT result;
19221922
r243487r243488
19261926   m_hash = m_texture_manager->texture_compute_hash(texsource, flags);
19271927   m_flags = flags;
19281928   m_texinfo = *texsource;
1929   m_xprescale = video_config.prescale;
1930   m_yprescale = video_config.prescale;
1929   m_xprescale = prescale;
1930   m_yprescale = prescale;
19311931
19321932   m_d3dtex = NULL;
19331933   m_d3dsurface = NULL;
r243487r243488
19861986      {
19871987         m_yprescale--;
19881988      }
1989      if (m_xprescale != video_config.prescale || m_yprescale != video_config.prescale)
1989
1990      int prescale = m_renderer->window().prescale();
1991      if (m_xprescale != prescale || m_yprescale != prescale)
19901992      {
1991         osd_printf_verbose("Direct3D: adjusting prescale from %dx%d to %dx%d\n", video_config.prescale, video_config.prescale, m_xprescale, m_yprescale);
1993         osd_printf_verbose("Direct3D: adjusting prescale from %dx%d to %dx%d\n", prescale, prescale, m_xprescale, m_yprescale);
19921994      }
19931995
19941996      // loop until we allocate something or error
r243487r243488
20082010            {
20092011               m_d3dfinaltex = m_d3dtex;
20102012               m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN;
2011
20122013               if (m_renderer->get_shaders()->enabled() && !m_renderer->get_shaders()->register_texture(this))
20132014               {
20142015                  goto error;
trunk/src/osd/windows/drawd3d.h
r243487r243488
9999{
100100public:
101101   //renderer() { }
102   renderer(win_window_info *window);
102   renderer(osd_window *window);
103103   virtual ~renderer();
104104
105105   virtual int create();
r243487r243488
112112
113113   int                     initialize();
114114
115   int                     device_create();
115   int                     device_create(HWND device_HWND);
116116   int                     device_create_resources();
117117   void                    device_delete();
118118   void                    device_delete_resources();
trunk/src/osd/windows/drawdd.c
r243487r243488
3939class renderer_dd : public osd_renderer
4040{
4141public:
42   renderer_dd(win_window_info *window)
42   renderer_dd(osd_window *window)
4343   : osd_renderer(window, FLAG_NONE),
4444      //adapter(0),
4545      adapter_ptr(NULL),
r243487r243488
140140/* mode_enum_info holds information during a display mode enumeration */
141141struct mode_enum_info
142142{
143   win_window_info *      window;
143   renderer_dd *         renderer;
144   osd_window  *         window;
144145   INT32                   minimum_width, minimum_height;
145146   INT32                   target_width, target_height;
146147   double                  target_refresh;
r243487r243488
191192//  drawnone_create
192193//============================================================
193194
194static osd_renderer *drawdd_create(win_window_info *window)
195static osd_renderer *drawdd_create(osd_window *window)
195196{
196197   return global_alloc(renderer_dd(window));
197198}
r243487r243488
833834   // hardware stretch case: apply prescale
834835   if (video_config.hwstretch)
835836   {
836      int prescale = (video_config.prescale < 1) ? 1 : video_config.prescale;
837      int prescale = (window().prescale() < 1) ? 1 : window().prescale();
837838
838839      // clamp the prescale to something smaller than the target bounds
839840      xscale = prescale;
r243487r243488
12061207{
12071208   float size_score, refresh_score, final_score;
12081209   mode_enum_info *einfo = (mode_enum_info *)context;
1209   renderer_dd *dd = dynamic_cast<renderer_dd *>(einfo->window->m_renderer);
1210   renderer_dd *dd = einfo->renderer;
12101211
12111212   // skip non-32 bit modes
12121213   if (desc->ddpfPixelFormat.dwRGBBitCount != 32)
r243487r243488
12711272   window().target()->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);
12721273
12731274   // use those as the target for now
1274   einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
1275   einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale);
1275   einfo.target_width = einfo.minimum_width * MAX(1, window().prescale());
1276   einfo.target_height = einfo.minimum_height * MAX(1, window().prescale());
12761277
12771278   // determine the refresh rate of the primary screen
12781279   einfo.target_refresh = 60.0;
r243487r243488
12891290   }
12901291
12911292   // if we are stretching, aim for a mode approximately 2x the game's resolution
1292   else if (video_config.prescale <= 1)
1293   else if (window().prescale() <= 1)
12931294   {
12941295      einfo.target_width *= 2;
12951296      einfo.target_height *= 2;
12961297   }
12971298
12981299   // fill in the rest of the data
1299   einfo.window = dynamic_cast<win_window_info *>(&window());
1300   einfo.window = &window();
1301   einfo.renderer = this;
13001302   einfo.best_score = 0.0f;
13011303
13021304   // enumerate the modes
trunk/src/osd/windows/drawgdi.c
r243487r243488
2525class renderer_gdi : public osd_renderer
2626{
2727public:
28   renderer_gdi(win_window_info *window)
28   renderer_gdi(osd_window *window)
2929   : osd_renderer(window, FLAG_NONE), bmdata(NULL), bmsize(0) { }
3030
3131   virtual ~renderer_gdi() { }
r243487r243488
5757//  drawnone_create
5858//============================================================
5959
60static osd_renderer *drawgdi_create(win_window_info *window)
60static osd_renderer *drawgdi_create(osd_window *window)
6161{
6262   return global_alloc(renderer_gdi(window));
6363}
trunk/src/osd/windows/drawnone.c
r243487r243488
2020class renderer_none : public osd_renderer
2121{
2222public:
23   renderer_none(win_window_info *window)
23   renderer_none(osd_window *window)
2424   : osd_renderer(window, FLAG_NONE) { }
2525
2626   virtual ~renderer_none() { }
r243487r243488
4747//  drawnone_create
4848//============================================================
4949
50osd_renderer *drawnone_create(win_window_info *window)
50osd_renderer *drawnone_create(osd_window *window)
5151{
5252   return global_alloc(renderer_none(window));
5353}
trunk/src/osd/windows/window.c
r243487r243488
297297
298298
299299win_window_info::win_window_info(running_machine &machine)
300      : m_next(NULL),
300      : osd_window(), m_next(NULL),
301301      m_init_state(0),
302302      m_startmaximized(0),
303303      m_isminimized(0),
r243487r243488
320320   m_non_fullscreen_bounds.top = 0;
321321   m_non_fullscreen_bounds.right  = 0;
322322   m_non_fullscreen_bounds.bottom = 0;
323   m_prescale = video_config.prescale;
323324}
324325
325326win_window_info::~win_window_info()
trunk/src/osd/windows/window.h
r243487r243488
3232//  TYPE DEFINITIONS
3333//============================================================
3434
35/* ------------------------------------------------------
36 *
37 * All types named osd_* will ultimately be located in
38 * the modules tree. They are temporarily maintained in
39 * window.h until basic code simplification is finished.
40 *
41 */
42
3543class win_window_info;
3644
3745class osd_window
r243487r243488
4654      m_maxwidth(0), m_maxheight(0),
4755      m_refresh(0),
4856#endif
57      m_prescale(1),
4958      m_primlist(NULL)
5059       {}
5160   virtual ~osd_window() { }
r243487r243488
5463   virtual int fullscreen() const = 0;
5564   virtual running_machine &machine() const = 0;
5665
66   int prescale() const { return m_prescale; };
67
5768#ifdef OSD_SDL
5869   virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
5970   virtual sdl_monitor_info *monitor() const = 0;
6071   virtual void get_size(int &w, int &h) = 0;
61   virtual int index() const = 0;
62   virtual int prescale() const = 0;
6372#if (SDLMAME_SDL2)
6473   virtual SDL_Window *sdl_window() = 0;
6574#else
r243487r243488
7483
7584   // window handle and info
7685   HWND               m_hwnd;
86   // FIXME: this is the same as win_window_list->m_hwnd, i.e. first window.
87   // During modularization, this should be passed in differently
7788   HWND                   m_focus_hwnd;
7889
7990   // monitor info
r243487r243488
8394   int                    m_refresh;
8495#endif
8596
97   int                  m_prescale;
8698   render_primitive_list *   m_primlist;
87
8899};
89100
90101class osd_renderer
r243487r243488
94105   /* Generic flags */
95106   static const int FLAG_NONE                = 0x0000;
96107   static const int FLAG_NEEDS_OPENGL          = 0x0001;
108   static const int FLAG_HAS_VECTOR_SCREEN      = 0x0002;
97109
98110   /* SDL 1.2 flags */
99111   static const int FLAG_NEEDS_DOUBLEBUF       = 0x0100;
r243487r243488
105117   virtual ~osd_renderer() { }
106118
107119   osd_window &window() { return *m_window; }
108   int flags() const { return m_flags; }
109120   bool has_flags(const int flag) { return ((m_flags & flag)) == flag; }
121   void set_flags(int aflag) { m_flags |= aflag; }
122   void clear_flags(int aflag) { m_flags &= ~aflag; }
110123
124
111125   void notify_changed() { set_flags(FI_CHANGED); }
112126
113127   /* Interface to be implemented by render code */
r243487r243488
131145   /* Internal flags */
132146   static const int FI_CHANGED                = 0x010000;
133147
134   void set_flags(int aflag) { m_flags |= aflag; }
135   void clear_flags(int aflag) { m_flags &= ~aflag; }
136
137148private:
138149
139150   osd_window      *m_window;
r243487r243488
196207
197208struct osd_draw_callbacks
198209{
199   osd_renderer *(*create)(win_window_info *window);
210   osd_renderer *(*create)(osd_window *window);
200211   void (*exit)(void);
201212};
202213


Previous 199869 Revisions Next


© 1997-2024 The MAME Team