Previous 199869 Revisions Next

r20246 Sunday 13th January, 2013 at 15:07:11 UTC by Ryan Holtz
- d3dhlsl.c: Made HLSL switchable at runtime, Ctrl+Alt+F12. [MooglyGuy]
[src/osd/windows]d3dhlsl.c d3dhlsl.h drawd3d.c drawd3d.h drawdd.c drawgdi.c drawnone.c input.c video.c window.c window.h

trunk/src/osd/windows/d3dhlsl.h
r20245r20246
116116   void init_fsfx_quad(void *vertbuf);
117117
118118   bool enabled() { return master_enable; }
119   void toggle();
119120
120121   bool vector_enabled() { return vector_enable && (bool)HLSL_VECTOR; }
121122   d3d_render_target* get_vector_target(d3d_info *d3d);
r20245r20246
206207   int                     snap_height;                // snapshot height
207208   bool                    lines_pending;              // whether or not we have lines to flush on the next quad
208209
210   bool               initialized;            // whether or not we're initialize
211
209212   // HLSL effects
210213   d3d_surface *           backbuffer;                 // pointer to our device's backbuffer
211214   d3d_effect *            curr_effect;                // pointer to the currently active effect object
trunk/src/osd/windows/drawdd.c
r20245r20246
223223   callbacks->window_draw = drawdd_window_draw;
224224   callbacks->window_save = NULL;
225225   callbacks->window_record = NULL;
226   callbacks->window_toggle_fsfx = NULL;
226227   callbacks->window_destroy = drawdd_window_destroy;
227228
228229   mame_printf_verbose("DirectDraw: Using DirectDraw 7\n");
trunk/src/osd/windows/window.c
r20245r20246
522522
523523
524524//============================================================
525//  winwindow_toggle_fsfx
526//  (main thread)
527//============================================================
528
529void winwindow_toggle_fsfx(void)
530{
531   if (draw.window_toggle_fsfx == NULL)
532      return;
533
534   win_window_info *window;
535
536   assert(GetCurrentThreadId() == main_threadid);
537
538   // iterate over windows and request a snap
539   for (window = win_window_list; window != NULL; window = window->next)
540   {
541      (*draw.window_toggle_fsfx)(window);
542   }
543}
544
545
546
547//============================================================
525548//  winwindow_take_video
526549//  (main thread)
527550//============================================================
trunk/src/osd/windows/window.h
r20245r20246
123123   int (*window_draw)(win_window_info *window, HDC dc, int update);
124124   void (*window_save)(win_window_info *window);
125125   void (*window_record)(win_window_info *window);
126   void (*window_toggle_fsfx)(win_window_info *window);
126127   void (*window_destroy)(win_window_info *window);
127128};
128129
r20245r20246
158159void winwindow_toggle_full_screen(void);
159160void winwindow_take_snap(void);
160161void winwindow_take_video(void);
162void winwindow_toggle_fsfx(void);
161163
162164void winwindow_process_events_periodic(running_machine &machine);
163165void winwindow_process_events(running_machine &machine, int ingame);
trunk/src/osd/windows/drawgdi.c
r20245r20246
9393   callbacks->window_draw = drawgdi_window_draw;
9494   callbacks->window_save = NULL;
9595   callbacks->window_record = NULL;
96   callbacks->window_toggle_fsfx = NULL;
9697   callbacks->window_destroy = drawgdi_window_destroy;
9798   return 0;
9899}
trunk/src/osd/windows/input.c
r20245r20246
779779         // alt-F12 for fullscreen snap
780780         case IPT_OSD_2:
781781            entry->configure_osd("RENDER_SNAP", "Take Rendered Snapshot");
782            entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_F12);
782            entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_F12, input_seq::not_code, KEYCODE_LCONTROL);
783783            break;
784784
785785         // alt-F11 for fullscreen video
r20245r20246
788788            entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_F11);
789789            break;
790790
791         // ctrl-alt-F12 to toggle post-processing
792         case IPT_OSD_4:
793            entry->configure_osd("POST_PROCESS", "Toggle Post-Processing");
794            entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_LALT, KEYCODE_LCONTROL, KEYCODE_F12);
795            break;
796
791797         // leave everything else alone
792798         default:
793799            break;
trunk/src/osd/windows/video.c
r20245r20246
374374   // check for taking fullscreen video
375375   if (ui_input_pressed(machine, IPT_OSD_3))
376376      winwindow_take_video();
377
378   // check for taking fullscreen video
379   if (ui_input_pressed(machine, IPT_OSD_4))
380      winwindow_toggle_fsfx();
377381}
378382
379383
trunk/src/osd/windows/drawnone.c
r20245r20246
7777   callbacks->window_draw = drawnone_window_draw;
7878   callbacks->window_save = NULL;
7979   callbacks->window_record = NULL;
80   callbacks->window_toggle_fsfx = NULL;
8081   callbacks->window_destroy = drawnone_window_destroy;
8182   return 0;
8283}
trunk/src/osd/windows/drawd3d.c
r20245r20246
217217      d3d->last_texture = texture;
218218      d3d->last_texture_flags = (texture == NULL ? 0 : texture->flags);
219219      result = (*d3dintf->device.set_texture)(d3d->device, 0, (texture == NULL) ? d3d->default_texture->d3dfinaltex : texture->d3dfinaltex);
220      if (d3d->hlsl != NULL)
221         d3d->hlsl->set_texture(texture);
220      d3d->hlsl->set_texture(texture);
222221      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture call\n", (int)result);
223222   }
224223}
r20245r20246
348347static render_primitive_list *drawd3d_window_get_primitives(win_window_info *window);
349348static void drawd3d_window_save(win_window_info *window);
350349static void drawd3d_window_record(win_window_info *window);
350static void drawd3d_window_toggle_fsfx(win_window_info *window);
351351static int drawd3d_window_draw(win_window_info *window, HDC dc, int update);
352352
353353// devices
r20245r20246
412412   callbacks->window_draw = drawd3d_window_draw;
413413   callbacks->window_save = drawd3d_window_save;
414414   callbacks->window_record = drawd3d_window_record;
415   callbacks->window_toggle_fsfx = drawd3d_window_toggle_fsfx;
415416   callbacks->window_destroy = drawd3d_window_destroy;
416417   return 0;
417418}
r20245r20246
440441
441442   // allocate memory for our structures
442443   d3d = global_alloc_clear(d3d_info);
444   d3d->restarting = false;
443445   window->drawdata = d3d;
444446   d3d->window = window;
445447   d3d->hlsl = NULL;
r20245r20246
475477
476478
477479
480static void drawd3d_window_toggle_fsfx(win_window_info *window)
481{
482   d3d_info *d3d = (d3d_info *)window->drawdata;
483
484   d3d->restarting = true;
485}
486
478487static void drawd3d_window_record(win_window_info *window)
479488{
480489   d3d_info *d3d = (d3d_info *)window->drawdata;
481490
482   if (d3d->hlsl != NULL)
483      d3d->hlsl->window_record();
491   d3d->hlsl->window_record();
484492}
485493
486494static void drawd3d_window_save(win_window_info *window)
487495{
488496   d3d_info *d3d = (d3d_info *)window->drawdata;
489497
490   if (d3d->hlsl != NULL)
491      d3d->hlsl->window_save();
498   d3d->hlsl->window_save();
492499}
493500
494501
r20245r20246
551558   if (window->resize_state == RESIZE_STATE_RESIZING)
552559      return 0;
553560
561   // if we're restarting the renderer, leave things alone
562   if (d3d->restarting)
563   {
564      d3d->hlsl->toggle();
565
566      // free all existing resources and re-create
567      device_delete_resources(d3d);
568      device_create_resources(d3d);
569
570      d3d->restarting = false;
571   }
572
554573   // if we haven't been created, just punt
555574   if (d3d == NULL)
556575      return 1;
r20245r20246
811830            VERTEX_BASE_FORMAT | ((d3d->hlsl->enabled() && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW), D3DPOOL_DEFAULT, &d3d->vertexbuf);
812831   if (result != D3D_OK)
813832   {
814      mame_printf_error("Error creating vertex buffer (%08X)", (UINT32)result);
833      printf("Error creating vertex buffer (%08X)", (UINT32)result);
815834      return 1;
816835   }
817836
trunk/src/osd/windows/d3dhlsl.c
r20245r20246
203203   lastidx = -1;
204204   targethead = NULL;
205205   cachehead = NULL;
206   initialized = false;
206207}
207208
208209
r20245r20246
498499
499500
500501//============================================================
502//  hlsl_info::set_texture
503//============================================================
504
505void hlsl_info::toggle()
506{
507   if (master_enable)
508   {
509      if (initialized)
510      {
511         delete_resources(false);
512      }
513   }
514   else
515   {
516      if (!initialized)
517      {
518         create_resources(false);
519      }
520   }
521
522   master_enable = !master_enable;
523}
524
525//============================================================
501526//  hlsl_info::begin_avi_recording
502527//============================================================
503528
r20245r20246
655680   }
656681}
657682
683
658684//============================================================
659685//  hlsl_info::set_texture
660686//============================================================
r20245r20246
698724   if (!d3dintf->post_fx_available)
699725      return;
700726
727   g_slider_list = init_slider_list();
728
701729   this->d3dintf = d3dintf;
702730   this->window = window;
703731
r20245r20246
712740
713741   snap_width = downcast<windows_options &>(window->machine().options()).d3d_snap_width();
714742   snap_height = downcast<windows_options &>(window->machine().options()).d3d_snap_height();
715}
716743
744   prescale_force_x = 0;
745   prescale_force_y = 0;
717746
718//============================================================
719//  hlsl_info::init_fsfx_quad
720//============================================================
747   windows_options &winoptions = downcast<windows_options &>(window->machine().options());
721748
722void hlsl_info::init_fsfx_quad(void *vertbuf)
723{
724   if (!master_enable || !d3dintf->post_fx_available)
725      return;
749   options = (hlsl_options*)global_alloc_clear(hlsl_options);
726750
727   d3d_info *d3d = (d3d_info *)window->drawdata;
751   options->params_dirty = true;
752   strcpy(options->shadow_mask_texture, downcast<windows_options &>(window->machine().options()).screen_shadow_mask_texture()); // unsafe
728753
729   // get a pointer to the vertex buffer
730   fsfx_vertices = (d3d_vertex *)vertbuf;
731   if (fsfx_vertices == NULL)
732      return;
754   write_ini = downcast<windows_options &>(window->machine().options()).hlsl_write_ini();
755   read_ini = downcast<windows_options &>(window->machine().options()).hlsl_read_ini();
733756
734   // fill in the vertexes clockwise
735   fsfx_vertices[0].x = 0.0f;
736   fsfx_vertices[0].y = 0.0f;
737   fsfx_vertices[1].x = d3d->width;
738   fsfx_vertices[1].y = 0.0f;
739   fsfx_vertices[2].x = 0.0f;
740   fsfx_vertices[2].y = d3d->height;
741   fsfx_vertices[3].x = d3d->width;
742   fsfx_vertices[3].y = 0.0f;
743   fsfx_vertices[4].x = 0.0f;
744   fsfx_vertices[4].y = d3d->height;
745   fsfx_vertices[5].x = d3d->width;
746   fsfx_vertices[5].y = d3d->height;
747
748   fsfx_vertices[0].u0 = 0.0f;
749   fsfx_vertices[0].v0 = 0.0f;
750
751   fsfx_vertices[1].u0 = 1.0f;
752   fsfx_vertices[1].v0 = 0.0f;
753
754   fsfx_vertices[2].u0 = 0.0f;
755   fsfx_vertices[2].v0 = 1.0f;
756
757   fsfx_vertices[3].u0 = 1.0f;
758   fsfx_vertices[3].v0 = 0.0f;
759
760   fsfx_vertices[4].u0 = 0.0f;
761   fsfx_vertices[4].v0 = 1.0f;
762
763   fsfx_vertices[5].u0 = 1.0f;
764   fsfx_vertices[5].v0 = 1.0f;
765
766   // set the color, Z parameters to standard values
767   for (int i = 0; i < 6; i++)
757   if(read_ini)
768758   {
769      fsfx_vertices[i].z = 0.0f;
770      fsfx_vertices[i].rhw = 1.0f;
771      fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
772   }
773}
759      emu_file ini_file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_READ | OPEN_FLAG_CREATE_PATHS);
760      file_error filerr = open_next((d3d_info*)window->drawdata, ini_file, downcast<windows_options &>(window->machine().options()).hlsl_ini_name(), "ini", 0);
774761
775
776//============================================================
777//  hlsl_info::create_resources
778//============================================================
779
780int hlsl_info::create_resources(bool reset)
781{
782   if (!master_enable || !d3dintf->post_fx_available)
783      return 0;
784
785   d3d_info *d3d = (d3d_info *)window->drawdata;
786
787   HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture);
788   if (result != D3D_OK)
789   {
790      mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
791      return 1;
792   }
793   (*d3dintf->texture.get_surface_level)(avi_copy_texture, 0, &avi_copy_surface);
794
795   result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &avi_final_texture);
796   if (result != D3D_OK)
797   {
798      mame_printf_verbose("Direct3D: Unable to init video-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
799      return 1;
800   }
801   (*d3dintf->texture.get_surface_level)(avi_final_texture, 0, &avi_final_target);
802
803   windows_options &winoptions = downcast<windows_options &>(window->machine().options());
804
805   if (!reset)
806   {
807      options = (hlsl_options*)global_alloc_clear(hlsl_options);
808
809      options->params_dirty = true;
810      strcpy(options->shadow_mask_texture, downcast<windows_options &>(window->machine().options()).screen_shadow_mask_texture()); // unsafe
811
812      write_ini = downcast<windows_options &>(window->machine().options()).hlsl_write_ini();
813      read_ini = downcast<windows_options &>(window->machine().options()).hlsl_read_ini();
814
815      if(read_ini)
762      read_ini = false;
763      if (filerr == FILERR_NONE)
816764      {
817         emu_file ini_file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_READ | OPEN_FLAG_CREATE_PATHS);
818         file_error filerr = open_next((d3d_info*)window->drawdata, ini_file, downcast<windows_options &>(window->machine().options()).hlsl_ini_name(), "ini", 0);
819
820         read_ini = false;
821         if (filerr == FILERR_NONE)
765         ini_file.seek(0, SEEK_END);
766         if (ini_file.tell() >= 1000)
822767         {
823            ini_file.seek(0, SEEK_END);
824            if (ini_file.tell() >= 1000)
825            {
826               read_ini = true;
827               ini_file.seek(0, SEEK_SET);
768            read_ini = true;
769            ini_file.seek(0, SEEK_SET);
828770
829               int en = 0;
830               char buf[1024];
831               ini_file.gets(buf, 1024);
832               sscanf(buf, "hlsl_enable %d\n", &en);
833               master_enable = en == 1;
771            int en = 0;
772            char buf[1024];
773            ini_file.gets(buf, 1024);
774            sscanf(buf, "hlsl_enable %d\n", &en);
775            master_enable = en == 1;
834776
835               ini_file.gets(buf, 1024);
836               sscanf(buf, "hlsl_prescale_x %d\n", &prescale_force_x);
777            ini_file.gets(buf, 1024);
778            sscanf(buf, "hlsl_prescale_x %d\n", &prescale_force_x);
837779
838               ini_file.gets(buf, 1024);
839               sscanf(buf, "hlsl_prescale_y %d\n", &prescale_force_y);
780            ini_file.gets(buf, 1024);
781            sscanf(buf, "hlsl_prescale_y %d\n", &prescale_force_y);
840782
841               ini_file.gets(buf, 1024);
842               sscanf(buf, "hlsl_preset %d\n", &preset);
783            ini_file.gets(buf, 1024);
784            sscanf(buf, "hlsl_preset %d\n", &preset);
843785
844               ini_file.gets(buf, 1024);
845               sscanf(buf, "hlsl_snap_width %d\n", &snap_width);
786            ini_file.gets(buf, 1024);
787            sscanf(buf, "hlsl_snap_width %d\n", &snap_width);
846788
847               ini_file.gets(buf, 1024);
848               sscanf(buf, "hlsl_snap_height %d\n", &snap_height);
789            ini_file.gets(buf, 1024);
790            sscanf(buf, "hlsl_snap_height %d\n", &snap_height);
849791
850               ini_file.gets(buf, 1024);
851               sscanf(buf, "shadow_mask_alpha %f\n", &options->shadow_mask_alpha);
792            ini_file.gets(buf, 1024);
793            sscanf(buf, "shadow_mask_alpha %f\n", &options->shadow_mask_alpha);
852794
853               ini_file.gets(buf, 1024);
854               sscanf(buf, "shadow_mask_texture %s\n", options->shadow_mask_texture);
795            ini_file.gets(buf, 1024);
796            sscanf(buf, "shadow_mask_texture %s\n", options->shadow_mask_texture);
855797
856               ini_file.gets(buf, 1024);
857               sscanf(buf, "shadow_mask_x_count %d\n", &options->shadow_mask_count_x);
798            ini_file.gets(buf, 1024);
799            sscanf(buf, "shadow_mask_x_count %d\n", &options->shadow_mask_count_x);
858800
859               ini_file.gets(buf, 1024);
860               sscanf(buf, "shadow_mask_y_count %d\n", &options->shadow_mask_count_y);
801            ini_file.gets(buf, 1024);
802            sscanf(buf, "shadow_mask_y_count %d\n", &options->shadow_mask_count_y);
861803
862               ini_file.gets(buf, 1024);
863               sscanf(buf, "shadow_mask_usize %f\n", &options->shadow_mask_u_size);
804            ini_file.gets(buf, 1024);
805            sscanf(buf, "shadow_mask_usize %f\n", &options->shadow_mask_u_size);
864806
865               ini_file.gets(buf, 1024);
866               sscanf(buf, "shadow_mask_vsize %f\n", &options->shadow_mask_v_size);
807            ini_file.gets(buf, 1024);
808            sscanf(buf, "shadow_mask_vsize %f\n", &options->shadow_mask_v_size);
867809
868               ini_file.gets(buf, 1024);
869               sscanf(buf, "curvature %f\n", &options->curvature);
810            ini_file.gets(buf, 1024);
811            sscanf(buf, "curvature %f\n", &options->curvature);
870812
871               ini_file.gets(buf, 1024);
872               sscanf(buf, "pincushion %f\n", &options->pincushion);
813            ini_file.gets(buf, 1024);
814            sscanf(buf, "pincushion %f\n", &options->pincushion);
873815
874               ini_file.gets(buf, 1024);
875               sscanf(buf, "scanline_alpha %f\n", &options->scanline_alpha);
816            ini_file.gets(buf, 1024);
817            sscanf(buf, "scanline_alpha %f\n", &options->scanline_alpha);
876818
877               ini_file.gets(buf, 1024);
878               sscanf(buf, "scanline_size %f\n", &options->scanline_scale);
819            ini_file.gets(buf, 1024);
820            sscanf(buf, "scanline_size %f\n", &options->scanline_scale);
879821
880               ini_file.gets(buf, 1024);
881               sscanf(buf, "scanline_height %f\n", &options->scanline_height);
822            ini_file.gets(buf, 1024);
823            sscanf(buf, "scanline_height %f\n", &options->scanline_height);
882824
883               ini_file.gets(buf, 1024);
884               sscanf(buf, "scanline_bright_scale %f\n", &options->scanline_bright_scale);
825            ini_file.gets(buf, 1024);
826            sscanf(buf, "scanline_bright_scale %f\n", &options->scanline_bright_scale);
885827
886               ini_file.gets(buf, 1024);
887               sscanf(buf, "scanline_bright_offset %f\n", &options->scanline_bright_offset);
828            ini_file.gets(buf, 1024);
829            sscanf(buf, "scanline_bright_offset %f\n", &options->scanline_bright_offset);
888830
889               ini_file.gets(buf, 1024);
890               sscanf(buf, "scanline_jitter %f\n", &options->scanline_offset);
831            ini_file.gets(buf, 1024);
832            sscanf(buf, "scanline_jitter %f\n", &options->scanline_offset);
891833
892               ini_file.gets(buf, 1024);
893               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
894               sscanf(buf, "defocus %f %f\n", &options->defocus[0], &options->defocus[1]);
834            ini_file.gets(buf, 1024);
835            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
836            sscanf(buf, "defocus %f %f\n", &options->defocus[0], &options->defocus[1]);
895837
896               ini_file.gets(buf, 1024);
897               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
898               sscanf(buf, "converge_x %f %f %f\n", &options->converge_x[0], &options->converge_x[1], &options->converge_x[2]);
838            ini_file.gets(buf, 1024);
839            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
840            sscanf(buf, "converge_x %f %f %f\n", &options->converge_x[0], &options->converge_x[1], &options->converge_x[2]);
899841
900               ini_file.gets(buf, 1024);
901               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
902               sscanf(buf, "converge_y %f %f %f\n", &options->converge_y[0], &options->converge_y[1], &options->converge_y[2]);
842            ini_file.gets(buf, 1024);
843            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
844            sscanf(buf, "converge_y %f %f %f\n", &options->converge_y[0], &options->converge_y[1], &options->converge_y[2]);
903845
904               ini_file.gets(buf, 1024);
905               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
906               sscanf(buf, "radial_converge_x %f %f %f\n", &options->radial_converge_x[0], &options->radial_converge_x[1], &options->radial_converge_x[2]);
846            ini_file.gets(buf, 1024);
847            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
848            sscanf(buf, "radial_converge_x %f %f %f\n", &options->radial_converge_x[0], &options->radial_converge_x[1], &options->radial_converge_x[2]);
907849
908               ini_file.gets(buf, 1024);
909               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
910               sscanf(buf, "radial_converge_y %f %f %f\n", &options->radial_converge_y[0], &options->radial_converge_y[1], &options->radial_converge_y[2]);
850            ini_file.gets(buf, 1024);
851            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
852            sscanf(buf, "radial_converge_y %f %f %f\n", &options->radial_converge_y[0], &options->radial_converge_y[1], &options->radial_converge_y[2]);
911853
912               ini_file.gets(buf, 1024);
913               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
914               sscanf(buf, "red_ratio %f %f %f\n", &options->red_ratio[0], &options->red_ratio[1], &options->red_ratio[2]);
854            ini_file.gets(buf, 1024);
855            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
856            sscanf(buf, "red_ratio %f %f %f\n", &options->red_ratio[0], &options->red_ratio[1], &options->red_ratio[2]);
915857
916               ini_file.gets(buf, 1024);
917               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
918               sscanf(buf, "grn_ratio %f %f %f\n", &options->grn_ratio[0], &options->grn_ratio[1], &options->grn_ratio[2]);
858            ini_file.gets(buf, 1024);
859            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
860            sscanf(buf, "grn_ratio %f %f %f\n", &options->grn_ratio[0], &options->grn_ratio[1], &options->grn_ratio[2]);
919861
920               ini_file.gets(buf, 1024);
921               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
922               sscanf(buf, "blu_ratio %f %f %f\n", &options->blu_ratio[0], &options->blu_ratio[1], &options->blu_ratio[2]);
862            ini_file.gets(buf, 1024);
863            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
864            sscanf(buf, "blu_ratio %f %f %f\n", &options->blu_ratio[0], &options->blu_ratio[1], &options->blu_ratio[2]);
923865
924               ini_file.gets(buf, 1024);
925               sscanf(buf, "saturation %f\n", &options->saturation);
866            ini_file.gets(buf, 1024);
867            sscanf(buf, "saturation %f\n", &options->saturation);
926868
927               ini_file.gets(buf, 1024);
928               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
929               sscanf(buf, "offset %f %f %f\n", &options->offset[0], &options->offset[1], &options->offset[2]);
869            ini_file.gets(buf, 1024);
870            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
871            sscanf(buf, "offset %f %f %f\n", &options->offset[0], &options->offset[1], &options->offset[2]);
930872
931               ini_file.gets(buf, 1024);
932               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
933               sscanf(buf, "scale %f %f %f\n", &options->scale[0], &options->scale[1], &options->scale[2]);
873            ini_file.gets(buf, 1024);
874            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
875            sscanf(buf, "scale %f %f %f\n", &options->scale[0], &options->scale[1], &options->scale[2]);
934876
935               ini_file.gets(buf, 1024);
936               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
937               sscanf(buf, "power %f %f %f\n", &options->power[0], &options->power[1], &options->power[2]);
877            ini_file.gets(buf, 1024);
878            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
879            sscanf(buf, "power %f %f %f\n", &options->power[0], &options->power[1], &options->power[2]);
938880
939               ini_file.gets(buf, 1024);
940               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
941               sscanf(buf, "floor %f %f %f\n", &options->floor[0], &options->floor[1], &options->floor[2]);
881            ini_file.gets(buf, 1024);
882            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
883            sscanf(buf, "floor %f %f %f\n", &options->floor[0], &options->floor[1], &options->floor[2]);
942884
943               ini_file.gets(buf, 1024);
944               for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
945               sscanf(buf, "phosphor_life %f %f %f\n", &options->phosphor[0], &options->phosphor[1], &options->phosphor[2]);
885            ini_file.gets(buf, 1024);
886            for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' ';
887            sscanf(buf, "phosphor_life %f %f %f\n", &options->phosphor[0], &options->phosphor[1], &options->phosphor[2]);
946888
947               ini_file.gets(buf, 1024);
948               sscanf(buf, "yiq_enable %d\n", &en);
949               options->yiq_enable = en == 1;
889            ini_file.gets(buf, 1024);
890            sscanf(buf, "yiq_enable %d\n", &en);
891            options->yiq_enable = en == 1;
950892
951               ini_file.gets(buf, 1024);
952               sscanf(buf, "yiq_cc %f\n", &options->yiq_cc);
893            ini_file.gets(buf, 1024);
894            sscanf(buf, "yiq_cc %f\n", &options->yiq_cc);
953895
954               ini_file.gets(buf, 1024);
955               sscanf(buf, "yiq_a %f\n", &options->yiq_a);
896            ini_file.gets(buf, 1024);
897            sscanf(buf, "yiq_a %f\n", &options->yiq_a);
956898
957               ini_file.gets(buf, 1024);
958               sscanf(buf, "yiq_b %f\n", &options->yiq_b);
899            ini_file.gets(buf, 1024);
900            sscanf(buf, "yiq_b %f\n", &options->yiq_b);
959901
960               ini_file.gets(buf, 1024);
961               sscanf(buf, "yiq_o %f\n", &options->yiq_o);
902            ini_file.gets(buf, 1024);
903            sscanf(buf, "yiq_o %f\n", &options->yiq_o);
962904
963               ini_file.gets(buf, 1024);
964               sscanf(buf, "yiq_p %f\n", &options->yiq_p);
905            ini_file.gets(buf, 1024);
906            sscanf(buf, "yiq_p %f\n", &options->yiq_p);
965907
966               ini_file.gets(buf, 1024);
967               sscanf(buf, "yiq_n %f\n", &options->yiq_n);
908            ini_file.gets(buf, 1024);
909            sscanf(buf, "yiq_n %f\n", &options->yiq_n);
968910
969               ini_file.gets(buf, 1024);
970               sscanf(buf, "yiq_y %f\n", &options->yiq_y);
911            ini_file.gets(buf, 1024);
912            sscanf(buf, "yiq_y %f\n", &options->yiq_y);
971913
972               ini_file.gets(buf, 1024);
973               sscanf(buf, "yiq_i %f\n", &options->yiq_i);
914            ini_file.gets(buf, 1024);
915            sscanf(buf, "yiq_i %f\n", &options->yiq_i);
974916
975               ini_file.gets(buf, 1024);
976               sscanf(buf, "yiq_q %f\n", &options->yiq_q);
917            ini_file.gets(buf, 1024);
918            sscanf(buf, "yiq_q %f\n", &options->yiq_q);
977919
978               ini_file.gets(buf, 1024);
979               sscanf(buf, "yiq_scan_time %f\n", &options->yiq_scan_time);
920            ini_file.gets(buf, 1024);
921            sscanf(buf, "yiq_scan_time %f\n", &options->yiq_scan_time);
980922
981               ini_file.gets(buf, 1024);
982               sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count);
983            }
923            ini_file.gets(buf, 1024);
924            sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count);
984925         }
985926      }
986927   }
987
988   // experimental: load a PNG to use for vector rendering; it is treated
989   // as a brightness map
990   emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ);
991
992   // experimental: if we have a shadow bitmap, create a texture for it
993   render_load_png(shadow_bitmap, file, NULL, options->shadow_mask_texture);
994   if (shadow_bitmap.valid())
928   else
995929   {
996      render_texinfo texture;
997
998      // fake in the basic data so it looks like it came from render.c
999      texture.base = shadow_bitmap.raw_pixptr(0);
1000      texture.rowpixels = shadow_bitmap.rowpixels();
1001      texture.width = shadow_bitmap.width();
1002      texture.height = shadow_bitmap.height();
1003      texture.palette = NULL;
1004      texture.seqid = 0;
1005
1006      // now create it
1007      shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
1008   }
1009
1010   prescale_force_x = 0;
1011   prescale_force_y = 0;
1012
1013   if(!read_ini)
1014   {
1015930      prescale_force_x = winoptions.d3d_hlsl_prescale_x();
1016931      prescale_force_y = winoptions.d3d_hlsl_prescale_y();
1017932      if(preset == -1)
r20245r20246
1063978      options->yiq_phase_count = winoptions.screen_yiq_phase_count();
1064979   }
1065980
1066   g_slider_list = init_slider_list();
981   options->params_dirty = true;
982   // experimental: load a PNG to use for vector rendering; it is treated
983   // as a brightness map
984   emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ);
1067985
986   render_load_png(shadow_bitmap, file, NULL, options->shadow_mask_texture);
987}
988
989
990//============================================================
991//  hlsl_info::init_fsfx_quad
992//============================================================
993
994void hlsl_info::init_fsfx_quad(void *vertbuf)
995{
996   if (!master_enable || !d3dintf->post_fx_available)
997      return;
998
999   d3d_info *d3d = (d3d_info *)window->drawdata;
1000
1001   // get a pointer to the vertex buffer
1002   fsfx_vertices = (d3d_vertex *)vertbuf;
1003   if (fsfx_vertices == NULL)
1004      return;
1005
1006   // fill in the vertexes clockwise
1007   fsfx_vertices[0].x = 0.0f;
1008   fsfx_vertices[0].y = 0.0f;
1009   fsfx_vertices[1].x = d3d->width;
1010   fsfx_vertices[1].y = 0.0f;
1011   fsfx_vertices[2].x = 0.0f;
1012   fsfx_vertices[2].y = d3d->height;
1013   fsfx_vertices[3].x = d3d->width;
1014   fsfx_vertices[3].y = 0.0f;
1015   fsfx_vertices[4].x = 0.0f;
1016   fsfx_vertices[4].y = d3d->height;
1017   fsfx_vertices[5].x = d3d->width;
1018   fsfx_vertices[5].y = d3d->height;
1019
1020   fsfx_vertices[0].u0 = 0.0f;
1021   fsfx_vertices[0].v0 = 0.0f;
1022
1023   fsfx_vertices[1].u0 = 1.0f;
1024   fsfx_vertices[1].v0 = 0.0f;
1025
1026   fsfx_vertices[2].u0 = 0.0f;
1027   fsfx_vertices[2].v0 = 1.0f;
1028
1029   fsfx_vertices[3].u0 = 1.0f;
1030   fsfx_vertices[3].v0 = 0.0f;
1031
1032   fsfx_vertices[4].u0 = 0.0f;
1033   fsfx_vertices[4].v0 = 1.0f;
1034
1035   fsfx_vertices[5].u0 = 1.0f;
1036   fsfx_vertices[5].v0 = 1.0f;
1037
1038   // set the color, Z parameters to standard values
1039   for (int i = 0; i < 6; i++)
1040   {
1041      fsfx_vertices[i].z = 0.0f;
1042      fsfx_vertices[i].rhw = 1.0f;
1043      fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
1044   }
1045}
1046
1047
1048//============================================================
1049//  hlsl_info::create_resources
1050//============================================================
1051
1052int hlsl_info::create_resources(bool reset)
1053{
1054   initialized = true;
1055
1056   d3d_info *d3d = (d3d_info *)window->drawdata;
1057
1058   HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture);
1059   if (result != D3D_OK)
1060   {
1061      mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
1062      return 1;
1063   }
1064   (*d3dintf->texture.get_surface_level)(avi_copy_texture, 0, &avi_copy_surface);
1065
1066   result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &avi_final_texture);
1067   if (result != D3D_OK)
1068   {
1069      mame_printf_verbose("Direct3D: Unable to init video-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
1070      return 1;
1071   }
1072   (*d3dintf->texture.get_surface_level)(avi_final_texture, 0, &avi_final_target);
1073
1074   // experimental: if we have a shadow bitmap, create a texture for it
1075   if (shadow_bitmap.valid())
1076   {
1077      render_texinfo texture;
1078
1079      // fake in the basic data so it looks like it came from render.c
1080      texture.base = shadow_bitmap.raw_pixptr(0);
1081      texture.rowpixels = shadow_bitmap.rowpixels();
1082      texture.width = shadow_bitmap.width();
1083      texture.height = shadow_bitmap.height();
1084      texture.palette = NULL;
1085      texture.seqid = 0;
1086
1087      // now create it
1088      shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
1089   }
1090
10681091   const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir();
10691092
10701093   // Replace all this garbage with a proper data-driven system
r20245r20246
20632086   if (!master_enable || !d3dintf->post_fx_available)
20642087      return;
20652088
2089   initialized = false;
2090
20662091   if(write_ini && !reset)
20672092   {
20682093      emu_file file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
r20245r20246
21992224      avi_final_target = NULL;
22002225   }
22012226
2202   global_free(options);
2203
22042227   shadow_bitmap.reset();
22052228}
22062229
trunk/src/osd/windows/drawd3d.h
r20245r20246
134134   d3d_poly_info           poly[VERTEX_BUFFER_SIZE/3]; // array to hold polygons as they are created
135135   int                     numpolys;                   // number of accumulated polygons
136136
137   bool               restarting;               // if we're restarting
138
137139   d3d_texture_info *      texlist;                    // list of active textures
138140   int                     dynamic_supported;          // are dynamic textures supported?
139141   int                     stretch_supported;          // is StretchRect with point filtering supported?

Previous 199869 Revisions Next


© 1997-2024 The MAME Team