Previous 199869 Revisions Next

r45064 Sunday 21st February, 2016 at 02:03:24 UTC by Ryan Holtz
More reshuffling, nw
[bgfx/chains]test.json*
[scripts/src/osd]modules.lua
[src/osd/modules]osdwindow.h
[src/osd/modules/render]drawbgfx.cpp drawbgfx.h drawd3d.h
[src/osd/modules/render/bgfx]chainentry.cpp* chainentry.h* chainentryreader.cpp* chainentryreader.h* inputpair.cpp* inputpair.h* pass.cpp pass.h passreader.cpp passreader.h slider.h* sliderreader.h*
[src/osd/modules/render/d3d]d3dhlsl.cpp
[src/osd/windows]video.cpp winmain.cpp winmain.h

trunk/bgfx/chains/test.json
r0r253576
1{   "name": "Test Shader Chain"
2   "author": "Ryan Holtz"
3   "sliders": [
4      { "type": "bool",  "name": "adjustments", "text": "Enable Adjustments", "default": false },
5      { "type": "float", "name": "ratio_amount", "text": "Ratio Amount", "default": 0, "max": 1 },
6
7      { "type": "color", "name": "red_ratios", "text": "Red Amount",   "default": [ 1, 0, 0 ]},
8      { "type": "color", "name": "grn_ratios", "text": "Green Amount", "default": [ 0, 1, 0 ], "max": 1, "min": 0 },
9      { "type": "color", "name": "blu_ratios", "text": "Blue Amount",  "default": [ 0, 0, 1 ], "max": 1, "min": 0 },
10      { "type": "color", "name": "tint": "text": "Tint", "default": [ 1, 1, 1 ], "max": 1, "min": 0 }
11      { "type": "color", "name": "phosphor", "text": "Phosphor Amount",  "default": [ 0, 0, 0 ], "max": 1, "min": 0 },
12      { "type": "vec2",  "name": "shift", "text": "Frame Shift", "default": [ 0, 0 ], "max": 25, "min": -25 },
13   ]
14   "parameters": [
15      { "name": "alternating", "type": "frame_mask", "period": 2 }
16   ]
17   "targets": [
18      {   "name": "native",
19         "screen": true,
20      },
21      {   "name": "previous",
22         "screen": true,
23         "prescale": true
24      }
25   ]
26   "passes": [
27      {   "effect": "ratios",
28         "name": "Matrix Pass"
29         "disable_conditions": [
30            { "type": "slider", "name": "adjustments", "value": false },
31            { "type": "slider", "name": "ratio_amount", "value": 0 }
32         ],
33         "uniforms": [
34            { "name": "u_ratio_amount", "slider": "ratio_amount" },
35            { "name": "u_red_ratios", "slider": "red_ratios" },
36            { "name": "u_grn_ratios", "slider": "grn_ratios" },
37            { "name": "u_blu_ratios", "slider": "blu_ratios" }
38         ],
39         "input": [
40            { "sampler": "s_tex", "texture": "screen" }
41         ],
42         "output": "native"
43      },
44      {   "effect": "tint",
45         "name": "Tint Pass"
46         "disable_conditions": [
47            { "type": "slider", "name": "adjustments", "value": false }
48         ],
49         "uniforms": [
50            { "name": "u_tint", "slider": "tint" },
51            { "name": "u_shift", "slider": "shift" }
52         ],
53         "input": [
54            { "sampler": "s_tex", "texture": "native" }
55         ],
56         "output": "native"
57      },
58      {   "effect": "phosphor"
59         "name": "Phosphor Decay",
60         "disable_conditions": [
61            { "type": "slider", "name": "adjustments", "value": false },
62            { "type": "slider", "name": "phosphor", "value": [ 0, 0, 0 ] }
63         ],
64         "uniforms": [
65            { "name": "u_passthrough", "value": [ 0.0f ] },
66            { "name": "u_phosphor", "slider": "phosphor" }
67         ],
68         "input": [
69            { "sampler": "s_tex", "texture": "native" },
70            { "sampler": "s_prev", "texture": "previous" }
71         ],
72         "output": "native"
73      },
74      {   "effect": "phosphor"
75         "name": "Phosphor Store",
76         "disable_conditions": [
77            { "type": "slider", "name": "adjustments", "value": false },
78            { "type": "slider", "name": "phosphor", "value": [ 0, 0, 0 ] }
79         ],
80         "uniforms": [
81            { "name": "u_passthrough", "value": [ 1.0f ] },
82            { "name": "u_phosphor", "slider": "phosphor" }
83         ],
84         "input": [
85            { "sampler": "s_tex", "texture": "native" },
86            { "sampler": "s_prev", "texture": "native" }
87         ],
88         "output": "previous"
89      },
90      {   "effect": "blit"
91         "name": "Final Blit",
92         "input": [
93            { "sampler": "s_tex", "texture": "native" }
94         ],
95         "output": "backbuffer"
96      }
97   ]
98}
No newline at end of file
trunk/scripts/src/osd/modules.lua
r253575r253576
109109      MAME_DIR .. "src/osd/modules/render/bgfx/effect.cpp",
110110      MAME_DIR .. "src/osd/modules/render/bgfx/effectmanager.cpp",
111111      MAME_DIR .. "src/osd/modules/render/bgfx/effectreader.cpp",
112      MAME_DIR .. "src/osd/modules/render/bgfx/pass.cpp",
113      MAME_DIR .. "src/osd/modules/render/bgfx/passreader.cpp",
112      MAME_DIR .. "src/osd/modules/render/bgfx/chainentry.cpp",
113      MAME_DIR .. "src/osd/modules/render/bgfx/chainentryreader.cpp",
114      MAME_DIR .. "src/osd/modules/render/bgfx/inputpair.cpp",
114115      MAME_DIR .. "src/osd/modules/render/bgfx/shadermanager.cpp",
115116      MAME_DIR .. "src/osd/modules/render/bgfx/statereader.cpp",
116117      MAME_DIR .. "src/osd/modules/render/bgfx/target.cpp",
trunk/src/osd/modules/osdwindow.h
r253575r253576
1010#define __OSDWINDOW__
1111
1212#include "emu.h"
13#include "ui/ui.h"
1314
1415//============================================================
1516//  TYPE DEFINITIONS
r253575r253576
221222   virtual int init(running_machine &machine) = 0;
222223   virtual render_primitive_list *get_primitives() = 0;
223224
225   virtual slider_state* get_slider_list() { return nullptr; }
224226   virtual int draw(const int update) = 0;
225227   virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) { return 0; };
226228   virtual void save() { };
trunk/src/osd/modules/render/bgfx/chainentry.cpp
r0r253576
1#include "emu.h"
2
3#include <bgfx/bgfx.h>
4
5#include "effect.h"
6#include "texture.h"
7#include "target.h"
8#include "chainentry.h"
9
10bgfx_chain_entry::bgfx_chain_entry(std::string name, bgfx_effect* effect, std::vector<bgfx_input_pair>& inputs, bgfx_target* output)
11   : m_name(name)
12   , m_effect(effect)
13   , m_output(output)
14{
15   for (bgfx_input_pair input : inputs)
16   {
17      m_inputs.push_back(input);
18   }
19}
20
21bgfx_chain_entry::~bgfx_chain_entry()
22{
23}
24
25void bgfx_chain_entry::submit(render_primitive* prim, int view)
26{
27   for (bgfx_input_pair input : m_inputs)
28   {
29      input.bind(m_effect);
30   }
31   bgfx::setViewFrameBuffer(view, m_output->target());
32   m_effect->submit(view);
33}
trunk/src/osd/modules/render/bgfx/chainentry.h
r0r253576
1#pragma once
2
3#ifndef __DRAWBGFX_CHAIN_ENTRY__
4#define __DRAWBGFX_CHAIN_ENTRY__
5
6#include <string>
7#include <vector>
8
9#include "inputpair.h"
10
11class render_primitive;
12class bgfx_effect;
13class bgfx_texture;
14class bgfx_target;
15
16class bgfx_chain_entry
17{
18public:
19    bgfx_chain_entry(std::string name, bgfx_effect* effect, std::vector<bgfx_input_pair>& inputs, bgfx_target* output);
20    ~bgfx_chain_entry();
21
22    void submit(render_primitive* prim, int view);
23
24    // Getters
25    std::string name() const { return m_name; }
26
27private:
28   std::string                  m_name;
29    bgfx_effect*               m_effect;
30    std::vector<bgfx_input_pair>   m_inputs;
31    bgfx_target*               m_output;
32};
33
34#endif // __DRAWBGFX_CHAIN_ENTRY__
No newline at end of file
trunk/src/osd/modules/render/bgfx/chainentryreader.cpp
r0r253576
1#include <string>
2
3#include "emu.h"
4
5#include "chainentryreader.h"
6
7#include "texturemanager.h"
8#include "targetmanager.h"
9#include "effectmanager.h"
10#include "chainentry.h"
11#include "inputpair.h"
12
13bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, texture_manager& textures, target_manager& targets, effect_manager& effects)
14{
15    validate_parameters(value);
16
17   bgfx_effect* effect = effects.effect(value["effect"].GetString());
18
19   std::vector<bgfx_input_pair> inputs;
20   if (value.HasMember("input"))
21   {
22      const Value& input_array = value["input"];
23      for (UINT32 i = 0; i < input_array.Size(); i++)
24      {
25         std::string sampler = input_array[i]["sampler"].GetString();
26         std::string texture = input_array[i]["texture"].GetString();
27         inputs.push_back(bgfx_input_pair(i, sampler, textures.texture(texture)));
28      }
29   }
30
31   bgfx_target* output = targets.target(value["output"].GetString());
32
33   return new bgfx_chain_entry(value["name"].GetString(), effect, inputs, output);
34}
35
36void chain_entry_reader::validate_parameters(const Value& value)
37{
38   assert(value.HasMember("effect"));
39   assert(value["effect"].IsString());
40   if (value.HasMember("name"))
41   {
42      assert(value["name"].IsString());
43   }
44   assert(value.HasMember("shader"));
45   assert(value["shader"].IsString());
46   assert(value.HasMember("output"));
47   assert(value["output"].IsString());
48}
No newline at end of file
trunk/src/osd/modules/render/bgfx/chainentryreader.h
r0r253576
1#pragma once
2
3#ifndef __DRAWBGFX_CHAIN_ENTRY_READER__
4#define __DRAWBGFX_CHAIN_ENTRY_READER__
5
6#include "statereader.h"
7
8class bgfx_chain_entry;
9class texture_manager;
10class target_manager;
11class effect_manager;
12
13class chain_entry_reader : public state_reader
14{
15public:
16    static bgfx_chain_entry* read_from_value(const Value& value, texture_manager& textures, target_manager& targets, effect_manager& effects);
17
18private:
19    static void validate_parameters(const Value& value);
20};
21
22#endif // __DRAWBGFX_CHAIN_ENTRY_READER__
No newline at end of file
trunk/src/osd/modules/render/bgfx/inputpair.cpp
r0r253576
1#include "inputpair.h"
2#include "texture.h"
3#include "effect.h"
4
5bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, bgfx_texture* texture)
6   : m_index(index)
7   , m_sampler(sampler)
8   , m_texture(texture)
9{
10}
11
12void bgfx_input_pair::bind(bgfx_effect *effect)
13{
14   bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), m_texture->handle());
15}
No newline at end of file
trunk/src/osd/modules/render/bgfx/inputpair.h
r0r253576
1#pragma once
2
3#ifndef __DRAWBGFX_INPUT_PAIR__
4#define __DRAWBGFX_INPUT_PAIR__
5
6#include <bgfx/bgfx.h>
7
8#include <string>
9
10class bgfx_effect;
11class bgfx_texture;
12
13class bgfx_input_pair
14{
15public:
16    bgfx_input_pair(int index, std::string sampler, bgfx_texture* texture);
17
18   void bind(bgfx_effect *effect);
19
20private:
21    int            m_index;
22    std::string    m_sampler;
23    bgfx_texture*   m_texture;
24};
25
26#endif // __DRAWBGFX_INPUT_PAIR__
No newline at end of file
trunk/src/osd/modules/render/bgfx/pass.cpp
r253575r253576
1#include "emu.h"
2
3#include <bgfx/bgfx.h>
4
5#include "effect.h"
6#include "texture.h"
7#include "target.h"
8#include "pass.h"
9
10bgfx_pass::bgfx_pass(std::string name, bgfx_effect* effect, std::vector<bgfx_texture*>& inputs, bgfx_target* output)
11   : m_name(name)
12   , m_effect(effect)
13   , m_output(output)
14{
15   for (bgfx_texture* input : inputs)
16   {
17      m_inputs.push_back(input);
18   }
19}
20
21bgfx_pass::~bgfx_pass()
22{
23}
24
25void bgfx_pass::submit(render_primitive* prim, int view)
26{
27   for (int index = 0; index < m_inputs.size(); index++)
28   {
29      bgfx::setTexture(index, m_effect->uniform(m_inputs[index]->name())->handle(), m_inputs[index]->handle());
30   }
31   bgfx::setViewFrameBuffer(view, m_output->target());
32   m_effect->submit(view);
33}
trunk/src/osd/modules/render/bgfx/pass.h
r253575r253576
1#pragma once
2
3#ifndef __DRAWBGFX_PASS__
4#define __DRAWBGFX_PASS__
5
6#include <string>
7#include <vector>
8
9class render_primitive;
10class bgfx_effect;
11class bgfx_texture;
12class bgfx_target;
13
14class bgfx_pass
15{
16public:
17    bgfx_pass(std::string name, bgfx_effect* effect, std::vector<bgfx_texture*>& inputs, bgfx_target* output);
18    ~bgfx_pass();
19
20    void submit(render_primitive* prim, int view);
21
22    // Getters
23    std::string name() const { return m_name; }
24
25private:
26   std::string               m_name;
27    bgfx_effect*            m_effect;
28    std::vector<bgfx_texture*>   m_inputs;
29    bgfx_target*            m_output;
30};
31
32#endif // __DRAWBGFX_PASS__
No newline at end of file
trunk/src/osd/modules/render/bgfx/passreader.cpp
r253575r253576
1#include <string>
2
3#include "emu.h"
4
5#include "passreader.h"
6
7#include "texturemanager.h"
8#include "targetmanager.h"
9#include "effectmanager.h"
10#include "pass.h"
11
12bgfx_pass* pass_reader::read_from_value(const Value& value, texture_manager& textures, target_manager& targets, effect_manager& effects)
13{
14    validate_parameters(value);
15
16   bgfx_effect* effect = effects.effect(value["effect"].GetString());
17
18   std::vector<bgfx_texture*> inputs;
19   if (value.HasMember("input"))
20   {
21      const Value& input_array = value["input"];
22      for (UINT32 i = 0; i < input_array.Size(); i++)
23      {
24         inputs.push_back(textures.texture(input_array[i].GetString()));
25      }
26   }
27
28   bgfx_target* output = targets.target(value["output"].GetString());
29
30   return new bgfx_pass(value["name"].GetString(), effect, inputs, output);
31}
32
33void pass_reader::validate_parameters(const Value& value)
34{
35   assert(value.HasMember("name"));
36   assert(value["name"].IsString());
37   assert(value.HasMember("output"));
38   assert(value["output"].IsString());
39   assert(value.HasMember("effect"));
40   assert(value["effect"].IsString());
41   if (value.HasMember("input"))
42   {
43      const Value& input_array = value["input"];
44      for (int i = 0; i < input_array.Size(); i++)
45      {
46         assert(uniform_array[i].IsString());
47      }
48   }
49}
No newline at end of file
trunk/src/osd/modules/render/bgfx/passreader.h
r253575r253576
1#pragma once
2
3#ifndef __DRAWBGFX_PASS_READER__
4#define __DRAWBGFX_PASS_READER__
5
6#include "statereader.h"
7
8class bgfx_pass;
9class texture_manager;
10class target_manager;
11class effect_manager;
12
13class pass_reader : public state_reader
14{
15public:
16    static bgfx_pass* read_from_value(const Value& value, texture_manager& textures, target_manager& targets, effect_manager& effects);
17
18private:
19    static void validate_parameters(const Value& value);
20};
21
22#endif // __DRAWBGFX_PASS_READER__
No newline at end of file
trunk/src/osd/modules/render/bgfx/slider.h
r0r253576
1#pragma once
2
3#ifndef __DRAWBGFX_SLIDER__
4#define __DRAWBGFX_SLIDER__
5
6#include <bgfx/bgfx.h>
7
8#include <string>
9#include <vector>
10#include <map>
11
12#include "uniform.h"
13
14class bgfx_slider
15{
16public:
17    bgfx_slider(slider_type type, std::string name, std::string description, void *defaults, void *min, void *max);
18    ~bgfx_slider();
19
20   enum slider_type
21   {
22      SLIDER_BOOL,
23      SLIDER_FLOAT,
24      SLIDER_INT,
25      SLIDER_COLOR,
26      SLIDER_VEC2
27   };
28
29    // Getters
30    bgfx_uniform* uniform(std::string name);
31    bgfx::ProgramHandle get_program() const { return m_program_handle; }
32
33protected:
34   std::string m_name;
35   void *   m_data;
36   void *   m_min;
37   void *   m_max;
38};
39
40#endif // __DRAWBGFX_SLIDER__
No newline at end of file
trunk/src/osd/modules/render/bgfx/sliderreader.h
r0r253576
1#pragma once
2
3#ifndef __DRAWBGFX_SLIDER_READER__
4#define __DRAWBGFX_SLIDER_READER__
5
6#include "statereader.h"
7
8class bgfx_slider;
9class shader_manager;
10
11class slider_reader : public state_reader
12{
13public:
14    static bgfx_slider* read_from_value(const Value& value);
15
16private:
17    static void validate_parameters(const Value& value);
18};
19
20#endif // __DRAWBGFX_SLIDER_READER__
No newline at end of file
trunk/src/osd/modules/render/d3d/d3dhlsl.cpp
r253575r253576
35253525//  get_slider_list
35263526//============================================================
35273527
3528slider_state *windows_osd_interface::get_slider_list()
3528slider_state *renderer_d3d9::get_slider_list()
35293529{
35303530   return g_slider_list;
35313531}
trunk/src/osd/modules/render/drawbgfx.cpp
r253575r253576
124124   m_effects = new effect_manager(*m_shaders);
125125
126126   // Create program from shaders.
127   printf("1\n"); fflush(stdout);
127128   m_gui_effect[0] = m_effects->effect("gui_opaque");
129   printf("2\n"); fflush(stdout);
128130   m_gui_effect[1] = m_effects->effect("gui_blend");
131   printf("3\n"); fflush(stdout);
129132   m_gui_effect[2] = m_effects->effect("gui_multiply");
133   printf("4\n"); fflush(stdout);
130134   m_gui_effect[3] = m_effects->effect("gui_add");
135   printf("5\n"); fflush(stdout);
131136
132137   m_screen_effect[0] = m_effects->effect("screen_opaque");
138   printf("6\n"); fflush(stdout);
133139   m_screen_effect[1] = m_effects->effect("screen_blend");
140   printf("7\n"); fflush(stdout);
134141   m_screen_effect[2] = m_effects->effect("screen_multiply");
142   printf("8\n"); fflush(stdout);
135143   m_screen_effect[3] = m_effects->effect("screen_add");
144   printf("9\n"); fflush(stdout);
136145
137146   uint32_t flags = BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT;
138147   m_texture_cache = m_textures->create_texture("#cache", bgfx::TextureFormat::RGBA8, CACHE_SIZE, CACHE_SIZE, nullptr, flags);
r253575r253576
10781087      bgfx::allocTransientVertexBuffer(buffer, vertices, ScreenVertex::ms_decl);
10791088   }
10801089}
1090
1091slider_state* renderer_bgfx::get_slider_list()
1092{
1093   return nullptr;
1094}
No newline at end of file
trunk/src/osd/modules/render/drawbgfx.h
r253575r253576
2828   virtual ~renderer_bgfx();
2929
3030   virtual int create() override;
31   virtual slider_state* get_slider_list() override;
3132   virtual int init(running_machine &machine) override { return 0; }
3233   virtual int draw(const int update) override;
3334#ifdef OSD_SDL
trunk/src/osd/modules/render/drawd3d.h
r253575r253576
4242   virtual ~renderer_d3d9();
4343
4444   virtual int create() override;
45   virtual slider_state* get_slider_list() override;
4546   virtual int init(running_machine &machine) override;
4647   virtual render_primitive_list *get_primitives() override;
4748   virtual int draw(const int update) override;
trunk/src/osd/windows/video.cpp
r253575r253576
1212
1313// MAME headers
1414#include "emu.h"
15#include "ui/ui.h"
1516#include "emuopts.h"
1617#include "render.h"
1718#include "uiinput.h"
r253575r253576
6667
6768bool windows_osd_interface::video_init()
6869{
69   int index;
70
7170   // extract data from the options
7271   extract_video_config();
7372
r253575r253576
7978
8079   // create the windows
8180   windows_options &options = downcast<windows_options &>(machine().options());
82   for (index = 0; index < video_config.numscreens; index++)
81   for (int index = 0; index < video_config.numscreens; index++)
82   {
8383      win_window_info::create(machine(), index, osd_monitor_info::pick_monitor(options, index), &windows[index]);
84   }
85
86   m_sliders = nullptr;
87   slider_state *curr = m_sliders;
88   for (win_window_info *info = win_window_list; info != nullptr; info = info->m_next)
89   {
90      slider_state *window_sliders = info->m_renderer->get_slider_list();
91      if (window_sliders != nullptr)
92      {
93         if (m_sliders == nullptr)
94         {
95            m_sliders = curr = window_sliders;
96         }
97         else
98         {
99            while (curr->next != nullptr)
100            {
101               curr = curr->next;
102            }
103            curr->next = window_sliders;
104         }
105      }
106   }
107
84108   if (video_config.mode != VIDEO_MODE_NONE)
85109      SetForegroundWindow(win_window_list->m_hwnd);
86110
87111   return true;
88112}
89113
114//============================================================
115//  get_slider_list
116//============================================================
90117
118slider_state *windows_osd_interface::get_slider_list()
119{
120   return m_sliders;
121}
122
91123//============================================================
92124//  video_exit
93125//============================================================
trunk/src/osd/windows/winmain.cpp
r253575r253576
5858public:
5959   // constructor which looks up the function
6060   dynamic_bind(const TCHAR *dll, const char *symbol)
61      : m_function(NULL)
61      : m_function(nullptr)
6262   {
6363      HMODULE module = LoadLibrary(dll);
64      if (module != NULL)
64      if (module != nullptr)
6565         m_function = reinterpret_cast<_FunctionPtr>(GetProcAddress(module, symbol));
6666   }
6767
68   // bool to test if the function is NULL or not
69   operator bool() const { return (m_function != NULL); }
68   // bool to test if the function is nullptr or not
69   operator bool() const { return (m_function != nullptr); }
7070
7171   // dereference to get the underlying pointer
7272   _FunctionPtr operator *() const { return m_function; }
r253575r253576
132132   bool parse_sym_line(const char *line, FPTR &address, std::string &symbol);
133133   bool parse_map_line(const char *line, FPTR &address, std::string &symbol);
134134   void scan_cache_for_address(FPTR address);
135   void format_symbol(const char *name, UINT32 displacement, const char *filename = NULL, int linenumber = 0);
135   void format_symbol(const char *name, UINT32 displacement, const char *filename = nullptr, int linenumber = 0);
136136
137137   static FPTR get_text_section_base();
138138
139139   struct cache_entry
140140   {
141141      cache_entry(FPTR address, const char *symbol) :
142         m_next(NULL), m_address(address), m_name(symbol) { }
142         m_next(nullptr), m_address(address), m_name(symbol) { }
143143      cache_entry *next() const { return m_next; }
144144
145145      cache_entry *   m_next;
r253575r253576
206206         char buffer[1024];
207207
208208         // if we are in fullscreen mode, go to windowed mode
209         if ((video_config.windowed == 0) && (win_window_list != NULL))
209         if ((video_config.windowed == 0) && (win_window_list != nullptr))
210210            winwindow_toggle_full_screen();
211211
212212         vsnprintf(buffer, ARRAY_LENGTH(buffer), msg, args);
213         win_message_box_utf8(win_window_list ? win_window_list->m_hwnd : NULL, buffer, emulator_info::get_appname(), MB_OK);
213         win_message_box_utf8(win_window_list ? win_window_list->m_hwnd : nullptr, buffer, emulator_info::get_appname(), MB_OK);
214214      }
215215      else
216216         chain_output(channel, msg, args);
r253575r253576
242242static int timeresult = !TIMERR_NOERROR;
243243static TIMECAPS timecaps;
244244
245static sampling_profiler *profiler = NULL;
246static symbol_manager *symbols = NULL;
245static sampling_profiler *profiler = nullptr;
246static symbol_manager *symbols = nullptr;
247247
248248bool stack_walker::s_initialized = false;
249249
r253575r253576
267267const options_entry windows_options::s_option_entries[] =
268268{
269269   // performance options
270   { NULL,                                           NULL,       OPTION_HEADER,     "WINDOWS PERFORMANCE OPTIONS" },
270   { nullptr,                                        nullptr,    OPTION_HEADER,     "WINDOWS PERFORMANCE OPTIONS" },
271271   { WINOPTION_PRIORITY "(-15-1)",                   "0",        OPTION_INTEGER,    "thread priority for the main game thread; range from -15 to 1" },
272272   { WINOPTION_PROFILE,                              "0",        OPTION_INTEGER,    "enables profiling, specifying the stack depth to track" },
273273
274274   // video options
275   { NULL,                                           NULL,       OPTION_HEADER,     "WINDOWS VIDEO OPTIONS" },
275   { nullptr,                                        nullptr,    OPTION_HEADER,     "WINDOWS VIDEO OPTIONS" },
276276   { WINOPTION_MENU,                                 "0",        OPTION_BOOLEAN,    "enables menu bar if available by UI implementation" },
277277
278278   // DirectDraw-specific options
279   { NULL,                                           NULL,       OPTION_HEADER,     "DIRECTDRAW-SPECIFIC OPTIONS" },
279   { nullptr,                                        nullptr,    OPTION_HEADER,     "DIRECTDRAW-SPECIFIC OPTIONS" },
280280   { WINOPTION_HWSTRETCH ";hws",                     "1",        OPTION_BOOLEAN,    "enables hardware stretching" },
281281
282282   // post-processing options
283   { NULL,                                                     NULL,                OPTION_HEADER,     "DIRECT3D POST-PROCESSING OPTIONS" },
284   { WINOPTION_HLSL_ENABLE";hlsl",                             "0",                 OPTION_BOOLEAN,    "enables HLSL post-processing (PS3.0 required)" },
285   { WINOPTION_HLSLPATH,                                       "hlsl",              OPTION_STRING,     "path to hlsl files" },
286   { WINOPTION_HLSL_PRESCALE_X,                                "0",                 OPTION_INTEGER,    "HLSL pre-scale override factor for X (0 for auto)" },
287   { WINOPTION_HLSL_PRESCALE_Y,                                "0",                 OPTION_INTEGER,    "HLSL pre-scale override factor for Y (0 for auto)" },
288   { WINOPTION_HLSL_WRITE,                                     NULL,                OPTION_STRING,     "enables HLSL AVI writing (huge disk bandwidth suggested)" },
283   { nullptr,                                                 nullptr,             OPTION_HEADER,     "DIRECT3D POST-PROCESSING OPTIONS" },
284   { WINOPTION_HLSL_ENABLE";hlsl",                            "0",                 OPTION_BOOLEAN,    "enables HLSL post-processing (PS3.0 required)" },
285   { WINOPTION_HLSLPATH,                                      "hlsl",              OPTION_STRING,     "path to hlsl files" },
286   { WINOPTION_HLSL_PRESCALE_X,                               "0",                 OPTION_INTEGER,    "HLSL pre-scale override factor for X (0 for auto)" },
287   { WINOPTION_HLSL_PRESCALE_Y,                               "0",                 OPTION_INTEGER,    "HLSL pre-scale override factor for Y (0 for auto)" },
288   { WINOPTION_HLSL_WRITE,                                    nullptr,             OPTION_STRING,     "enables HLSL AVI writing (huge disk bandwidth suggested)" },
289289   { WINOPTION_HLSL_SNAP_WIDTH,                                "2048",              OPTION_STRING,     "HLSL upscaled-snapshot width" },
290290   { WINOPTION_HLSL_SNAP_HEIGHT,                               "1536",              OPTION_STRING,     "HLSL upscaled-snapshot height" },
291291   { WINOPTION_SHADOW_MASK_TILE_MODE,                          "0",                 OPTION_INTEGER,    "shadow mask tile mode (0 for screen based, 1 for source based)" },
r253575r253576
326326   { WINOPTION_FLOOR";fs_floor",                               "0.05,0.05,0.05",    OPTION_STRING,     "signal floor level" },
327327   { WINOPTION_PHOSPHOR";fs_phosphor",                         "0.4,0.4,0.4",       OPTION_STRING,     "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
328328   /* NTSC simulation below this line */
329   { NULL,                                                     NULL,                OPTION_HEADER,     "NTSC POST-PROCESSING OPTIONS" },
329   { nullptr,                                                  nullptr,             OPTION_HEADER,     "NTSC POST-PROCESSING OPTIONS" },
330330   { WINOPTION_YIQ_ENABLE";yiq",                               "0",                 OPTION_BOOLEAN,    "enables YIQ-space HLSL post-processing" },
331331   { WINOPTION_YIQ_JITTER";yiqj",                              "0.0",               OPTION_FLOAT,      "Jitter for the NTSC signal processing" },
332332   { WINOPTION_YIQ_CCVALUE";yiqcc",                            "3.57954545",        OPTION_FLOAT,      "Color Carrier frequency for NTSC signal processing" },
r253575r253576
341341   { WINOPTION_YIQ_SCAN_TIME";yiqsc",                          "52.6",              OPTION_FLOAT,      "Horizontal scanline duration for NTSC signal processing (in usec)" },
342342   { WINOPTION_YIQ_PHASE_COUNT";yiqp",                         "2",                 OPTION_INTEGER,    "Phase Count value for NTSC signal processing" },
343343   /* Vector simulation below this line */
344   { NULL,                                                     NULL,                OPTION_HEADER,     "VECTOR POST-PROCESSING OPTIONS" },
344   { nullptr,                                                  nullptr,             OPTION_HEADER,     "VECTOR POST-PROCESSING OPTIONS" },
345345   { WINOPTION_VECTOR_LENGTH_SCALE";veclength",                "0.5",               OPTION_FLOAT,      "How much length affects vector fade" },
346346   { WINOPTION_VECTOR_LENGTH_RATIO";vecsize",                  "500.0",             OPTION_FLOAT,      "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
347347   /* Bloom below this line */
348   { NULL,                                                     NULL,                OPTION_HEADER,     "BLOOM POST-PROCESSING OPTIONS" },
348   { nullptr,                                                  nullptr,             OPTION_HEADER,     "BLOOM POST-PROCESSING OPTIONS" },
349349   { WINOPTION_BLOOM_BLEND_MODE,                               "0",                 OPTION_INTEGER,    "bloom blend mode (0 for addition, 1 for darken)" },
350350   { WINOPTION_BLOOM_SCALE,                                    "0.25",              OPTION_FLOAT,      "Intensity factor for bloom" },
351351   { WINOPTION_BLOOM_OVERDRIVE,                                "1.0,1.0,1.0",       OPTION_STRING,     "Overdrive factor for bloom" },
r253575r253576
362362   { WINOPTION_BLOOM_LEVEL10_WEIGHT,                           "0.01",              OPTION_FLOAT,      "Bloom level 10 (1x1 target) weight" },
363363
364364   // full screen options
365   { NULL,                                           NULL,       OPTION_HEADER,     "FULL SCREEN OPTIONS" },
365   { nullptr,                                        nullptr,    OPTION_HEADER,     "FULL SCREEN OPTIONS" },
366366   { WINOPTION_TRIPLEBUFFER ";tb",                   "0",        OPTION_BOOLEAN,    "enables triple buffering" },
367367   { WINOPTION_FULLSCREENBRIGHTNESS ";fsb(0.1-2.0)", "1.0",      OPTION_FLOAT,      "brightness value in full screen mode" },
368368   { WINOPTION_FULLSCREENCONTRAST ";fsc(0.1-2.0)",   "1.0",      OPTION_FLOAT,      "contrast value in full screen mode" },
369369   { WINOPTION_FULLSCREENGAMMA ";fsg(0.1-3.0)",      "1.0",      OPTION_FLOAT,      "gamma value in full screen mode" },
370370
371371   // input options
372   { NULL,                                           NULL,       OPTION_HEADER,     "INPUT DEVICE OPTIONS" },
372   { nullptr,                                        nullptr,    OPTION_HEADER,     "INPUT DEVICE OPTIONS" },
373373   { WINOPTION_GLOBAL_INPUTS ";global_inputs",       "0",        OPTION_BOOLEAN,    "enables global inputs" },
374374   { WINOPTION_DUAL_LIGHTGUN ";dual",                "0",        OPTION_BOOLEAN,    "enables dual lightgun input" },
375375
376   { NULL }
376   { nullptr }
377377};
378378
379379//**************************************************************************
r253575r253576
389389{
390390   // use small output buffers on non-TTYs (i.e. pipes)
391391   if (!isatty(fileno(stdout)))
392      setvbuf(stdout, (char *) NULL, _IOFBF, 64);
392      setvbuf(stdout, (char *) nullptr, _IOFBF, 64);
393393   if (!isatty(fileno(stderr)))
394      setvbuf(stderr, (char *) NULL, _IOFBF, 64);
394      setvbuf(stderr, (char *) nullptr, _IOFBF, 64);
395395
396396   // initialize common controls
397397   InitCommonControls();
r253575r253576
434434      osd_output::pop(&winerror);
435435   }
436436   // free symbols
437   symbols = NULL;
437   symbols = nullptr;
438438   return result;
439439}
440440
r253575r253576
469469
470470   // if we don't have a machine yet, or if we are handling ctrl+c/ctrl+break,
471471   // just terminate hard, without throwing or handling any atexit stuff
472   if (g_current_machine == NULL || type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)
472   if (g_current_machine == nullptr || type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)
473473   {
474474      fprintf(stderr, ", exiting\n");
475475      TerminateProcess(GetCurrentProcess(), MAMERR_FATALERROR);
r253575r253576
505505//============================================================
506506
507507windows_osd_interface::windows_osd_interface(windows_options &options)
508: osd_common_t(options), m_options(options)
508   : osd_common_t(options)
509   , m_options(options)
510   , m_sliders(nullptr)
509511{
510512}
511513
r253575r253576
525527
526528void windows_osd_interface::video_register()
527529{
528   video_options_add("gdi", NULL);
529   video_options_add("d3d", NULL);
530   video_options_add("bgfx", NULL);
531   //video_options_add("auto", NULL); // making d3d video default one
530   video_options_add("gdi", nullptr);
531   video_options_add("d3d", nullptr);
532   video_options_add("bgfx", nullptr);
533   //video_options_add("auto", nullptr); // making d3d video default one
532534}
533535
534536//============================================================
r253575r253576
589591
590592   // notify listeners of screen configuration
591593   std::string tempstring;
592   for (win_window_info *info = win_window_list; info != NULL; info = info->m_next)
594   for (win_window_info *info = win_window_list; info != nullptr; info = info->m_next)
593595   {
594596      strprintf(tempstring, "Orientation(%s)", info->m_monitor->devicename());
595597      machine.output().set_value(tempstring.c_str(), info->m_targetorient);
r253575r253576
609611   int watchdog = options.watchdog();
610612   if (watchdog != 0)
611613   {
612      watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL);
613      assert_always(watchdog_reset_event != NULL, "Failed to create watchdog reset event");
614      watchdog_exit_event = CreateEvent(NULL, TRUE, FALSE, NULL);
615      assert_always(watchdog_exit_event != NULL, "Failed to create watchdog exit event");
616      watchdog_thread = CreateThread(NULL, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, NULL);
617      assert_always(watchdog_thread != NULL, "Failed to create watchdog thread");
614      watchdog_reset_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
615      assert_always(watchdog_reset_event != nullptr, "Failed to create watchdog reset event");
616      watchdog_exit_event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
617      assert_always(watchdog_exit_event != nullptr, "Failed to create watchdog exit event");
618      watchdog_thread = CreateThread(nullptr, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, nullptr);
619      assert_always(watchdog_thread != nullptr, "Failed to create watchdog thread");
618620   }
619621
620622   // create and start the profiler
r253575r253576
639641void windows_osd_interface::osd_exit()
640642{
641643   // no longer have a machine
642   g_current_machine = NULL;
644   g_current_machine = nullptr;
643645
644646   // cleanup sockets
645647   win_cleanup_sockets();
r253575r253576
647649   osd_common_t::osd_exit();
648650
649651   // take down the watchdog thread if it exists
650   if (watchdog_thread != NULL)
652   if (watchdog_thread != nullptr)
651653   {
652654      SetEvent(watchdog_exit_event);
653655      WaitForSingleObject(watchdog_thread, INFINITE);
654656      CloseHandle(watchdog_reset_event);
655657      CloseHandle(watchdog_exit_event);
656658      CloseHandle(watchdog_thread);
657      watchdog_reset_event = NULL;
658      watchdog_exit_event = NULL;
659      watchdog_thread = NULL;
659      watchdog_reset_event = nullptr;
660      watchdog_exit_event = nullptr;
661      watchdog_thread = nullptr;
660662   }
661663
662664   // stop the profiler
663   if (profiler != NULL)
665   if (profiler != nullptr)
664666   {
665667      profiler->stop();
666668      profiler->print_results(*symbols);
r253575r253576
688690
689691   // walk the stack
690692   while (walker.unwind())
691      fprintf(stderr, "  %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == NULL) ? "" : symbols->symbol_for_address(walker.ip()));
693      fprintf(stderr, "  %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == nullptr) ? "" : symbols->symbol_for_address(walker.ip()));
692694}
693695
694696
r253575r253576
753755void winmain_watchdog_ping(void)
754756{
755757   // if we have a watchdog, reset it
756   if (watchdog_reset_event != NULL)
758   if (watchdog_reset_event != nullptr)
757759      SetEvent(watchdog_reset_event);
758760}
759761
r253575r253576
866868
867869   // walk the stack
868870   while (walker.unwind())
869      fprintf(stderr, "  %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == NULL) ? "" : symbols->symbol_for_address(walker.ip()));
871      fprintf(stderr, "  %p: %p%s\n", (void *)walker.frame(), (void *)walker.ip(), (symbols == nullptr) ? "" : symbols->symbol_for_address(walker.ip()));
870872
871873   // flush stderr, so the data is actually written when output is being redirected
872874   fflush(stderr);
r253575r253576
901903   // initialize the symbols
902904   if (!s_initialized && m_sym_initialize && m_stack_walk_64 && m_sym_function_table_access_64 && m_sym_get_module_base_64)
903905   {
904      (*m_sym_initialize)(m_process, NULL, TRUE);
906      (*m_sym_initialize)(m_process, nullptr, TRUE);
905907      s_initialized = true;
906908   }
907909}
r253575r253576
975977   if (s_initialized)
976978   {
977979#ifdef PTR64
978      return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_AMD64, m_process, m_thread, &m_stackframe, &m_context, NULL, *m_sym_function_table_access_64, *m_sym_get_module_base_64, NULL);
980      return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_AMD64, m_process, m_thread, &m_stackframe, &m_context, nullptr, *m_sym_function_table_access_64, *m_sym_get_module_base_64, nullptr);
979981#else
980      return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_I386, m_process, m_thread, &m_stackframe, &m_context, NULL, *m_sym_function_table_access_64, *m_sym_get_module_base_64, NULL);
982      return (*m_stack_walk_64)(IMAGE_FILE_MACHINE_I386, m_process, m_thread, &m_stackframe, &m_context, nullptr, *m_sym_function_table_access_64, *m_sym_get_module_base_64, nullptr);
981983#endif
982984   }
983985
r253575r253576
10561058   if (!query_system_for_address(address))
10571059   {
10581060      // if that fails, scan the cache if we have one
1059      if (m_cache.first() != NULL)
1061      if (m_cache.first() != nullptr)
10601062         scan_cache_for_address(address);
10611063
10621064      // or else try to open a sym/map file and find it there
r253575r253576
11131115void symbol_manager::scan_file_for_address(FPTR address, bool create_cache)
11141116{
11151117   bool is_symfile = false;
1116   FILE *srcfile = NULL;
1118   FILE *srcfile = nullptr;
11171119
11181120#ifdef __GNUC__
11191121   // see if we have a symbol file (gcc only)
11201122   srcfile = fopen(m_symfile.c_str(), "r");
1121   is_symfile = (srcfile != NULL);
1123   is_symfile = (srcfile != nullptr);
11221124#endif
11231125
11241126   // if not, see if we have a map file
1125   if (srcfile == NULL)
1127   if (srcfile == nullptr)
11261128      srcfile = fopen(m_mapfile.c_str(), "r");
11271129
11281130   // if not, fail
1129   if (srcfile == NULL)
1131   if (srcfile == nullptr)
11301132      return;
11311133
11321134   // reset the best info
r253575r253576
11791181   FPTR best_addr = 0;
11801182
11811183   // walk the cache, looking for valid entries
1182   for (cache_entry *entry = m_cache.first(); entry != NULL; entry = entry->next())
1184   for (cache_entry *entry = m_cache.first(); entry != nullptr; entry = entry->next())
11831185
11841186      // if this is the best one so far, remember it
11851187      if (entry->m_address <= address && entry->m_address > best_addr)
r253575r253576
12121214
12131215   // first look for a (ty) entry
12141216   const char *type = strstr(line, "(ty  20)");
1215   if (type == NULL)
1217   if (type == nullptr)
12161218      return false;
12171219
12181220   // scan forward in the line to find the address
r253575r253576
12991301      strcatprintf(m_buffer, "+0x%04x", (UINT32)displacement);
13001302
13011303   // append file/line if present
1302   if (filename != NULL)
1304   if (filename != nullptr)
13031305      strcatprintf(m_buffer, ", %s:%d", filename, linenumber);
13041306
13051307   // close up the string
r253575r253576
13191321
13201322   // start with the image base
13211323   PVOID base = reinterpret_cast<PVOID>(GetModuleHandleUni());
1322   assert(base != NULL);
1324   assert(base != nullptr);
13231325
13241326   // make sure we have the functions we need
13251327   if (image_nt_header && image_rva_to_section)
13261328   {
13271329      // get the NT header
13281330      PIMAGE_NT_HEADERS headers = (*image_nt_header)(base);
1329      assert(headers != NULL);
1331      assert(headers != nullptr);
13301332
13311333      // look ourself up (assuming we are in the .text section)
13321334      PIMAGE_SECTION_HEADER section = (*image_rva_to_section)(headers, base, reinterpret_cast<FPTR>(get_text_section_base) - reinterpret_cast<FPTR>(base));
1333      if (section != NULL)
1335      if (section != nullptr)
13341336         return reinterpret_cast<FPTR>(base) + section->VirtualAddress;
13351337   }
13361338
r253575r253576
13491351//-------------------------------------------------
13501352
13511353sampling_profiler::sampling_profiler(UINT32 max_seconds, UINT8 stack_depth = 0)
1352   :   m_target_thread(NULL),
1353      m_thread(NULL),
1354   :   m_target_thread(nullptr),
1355      m_thread(nullptr),
13541356      m_thread_id(0),
13551357      m_thread_exit(false),
13561358      m_stack_depth(stack_depth),
r253575r253576
13861388   m_thread_exit = false;
13871389
13881390   // start the thread
1389   m_thread = CreateThread(NULL, 0, thread_entry, (LPVOID)this, 0, &m_thread_id);
1390   assert_always(m_thread != NULL, "Failed to create profiler thread\n");
1391   m_thread = CreateThread(nullptr, 0, thread_entry, (LPVOID)this, 0, &m_thread_id);
1392   assert_always(m_thread != nullptr, "Failed to create profiler thread\n");
13911393
13921394   // max out the priority
13931395   SetThreadPriority(m_thread, THREAD_PRIORITY_TIME_CRITICAL);
r253575r253576
15551557         *count += 1;
15561558      }
15571559
1558      // fill in any missing parts with NULLs
1560      // fill in any missing parts with nulls
15591561      for (; frame <= m_stack_depth; frame++)
15601562         *m_buffer_ptr++ = 0;
15611563
trunk/src/osd/windows/winmain.h
r253575r253576
276276private:
277277   virtual void osd_exit() override;
278278   windows_options &m_options;
279   slider_state *m_sliders;
279280
280281   static const int DEFAULT_FONT_HEIGHT = 200;
281282};


Previous 199869 Revisions Next


© 1997-2024 The MAME Team