mirror of
https://github.com/holub/mame
synced 2025-10-04 08:28:39 +03:00
Per-screen sliders and some bugfixing, nw
This commit is contained in:
parent
9f48ad4fbb
commit
295aafc5e5
2
3rdparty/bgfx/src/config.h
vendored
2
3rdparty/bgfx/src/config.h
vendored
@ -266,7 +266,7 @@
|
||||
#endif // BGFX_CONFIG_MAX_TEXTURE_SAMPLERS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_FRAME_BUFFERS
|
||||
# define BGFX_CONFIG_MAX_FRAME_BUFFERS 64
|
||||
# define BGFX_CONFIG_MAX_FRAME_BUFFERS 128
|
||||
#endif // BGFX_CONFIG_MAX_FRAME_BUFFERS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
|
||||
|
@ -25,25 +25,19 @@ using namespace rapidjson;
|
||||
|
||||
chain_manager::~chain_manager()
|
||||
{
|
||||
for (std::pair<std::string, bgfx_chain*> chain : m_chains)
|
||||
for (bgfx_chain* chain : m_chains)
|
||||
{
|
||||
delete chain.second;
|
||||
delete chain;
|
||||
}
|
||||
m_chains.clear();
|
||||
}
|
||||
|
||||
bgfx_chain* chain_manager::chain(std::string name, running_machine& machine, uint32_t window_index)
|
||||
bgfx_chain* chain_manager::chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index)
|
||||
{
|
||||
std::map<std::string, bgfx_chain*>::iterator iter = m_chains.find(name + std::to_string(window_index));
|
||||
if (iter != m_chains.end())
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
return load_chain(name, machine, window_index);
|
||||
return load_chain(name, machine, window_index, screen_index);
|
||||
}
|
||||
|
||||
bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine, uint32_t window_index)
|
||||
bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index)
|
||||
{
|
||||
if (name.length() < 5 || (name.compare(name.length() - 5, 5, ".json")!= 0))
|
||||
{
|
||||
@ -76,7 +70,7 @@ bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bgfx_chain* chain = chain_reader::read_from_value(document, name + ": ", m_options, machine, window_index, m_textures, m_targets, m_effects, m_width, m_height);
|
||||
bgfx_chain* chain = chain_reader::read_from_value(document, name + ": ", m_options, machine, window_index, screen_index, m_textures, m_targets, m_effects, m_width, m_height);
|
||||
|
||||
if (chain == nullptr)
|
||||
{
|
||||
@ -84,7 +78,7 @@ bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_chains[name + std::to_string(window_index)] = chain;
|
||||
m_chains.push_back(chain);
|
||||
|
||||
return chain;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#ifndef __DRAWBGFX_CHAIN_MANAGER__
|
||||
#define __DRAWBGFX_CHAIN_MANAGER__
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "texturemanager.h"
|
||||
@ -39,10 +39,10 @@ public:
|
||||
~chain_manager();
|
||||
|
||||
// Getters
|
||||
bgfx_chain* chain(std::string name, running_machine& machine, uint32_t window_index);
|
||||
bgfx_chain* chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index);
|
||||
|
||||
private:
|
||||
bgfx_chain* load_chain(std::string name, running_machine& machine, uint32_t window_index);
|
||||
bgfx_chain* load_chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index);
|
||||
|
||||
osd_options& m_options;
|
||||
texture_manager& m_textures;
|
||||
@ -50,7 +50,7 @@ private:
|
||||
effect_manager& m_effects;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
std::map<std::string, bgfx_chain*> m_chains;
|
||||
std::vector<bgfx_chain*> m_chains;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_CHAIN_MANAGER__
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "slider.h"
|
||||
#include "parameter.h"
|
||||
|
||||
bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height)
|
||||
bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, uint32_t screen_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -41,7 +41,7 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix
|
||||
const Value& slider_array = value["sliders"];
|
||||
for (UINT32 i = 0; i < slider_array.Size(); i++)
|
||||
{
|
||||
std::vector<bgfx_slider*> expanded_sliders = slider_reader::read_from_value(slider_array[i], prefix + "sliders[" + std::to_string(i) + "]: ", machine, window_index);
|
||||
std::vector<bgfx_slider*> expanded_sliders = slider_reader::read_from_value(slider_array[i], prefix + "sliders[" + std::to_string(i) + "]: ", machine, window_index, screen_index);
|
||||
if (expanded_sliders.size() == 0)
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -21,7 +21,7 @@ class effect_manager;
|
||||
class chain_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static bgfx_chain* read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height);
|
||||
static bgfx_chain* read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, uint32_t screen_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
|
@ -33,7 +33,7 @@ const slider_reader::string_to_enum slider_reader::SCREEN_NAMES[slider_reader::S
|
||||
{ "all", uint64_t(bgfx_slider::screen_type::SLIDER_SCREEN_TYPE_ANY) }
|
||||
};
|
||||
|
||||
std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std::string prefix, running_machine& machine, uint32_t window_index)
|
||||
std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std::string prefix, running_machine& machine, uint32_t window_index, uint32_t screen_index)
|
||||
{
|
||||
std::vector<bgfx_slider*> sliders;
|
||||
|
||||
@ -83,6 +83,7 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
||||
break;
|
||||
}
|
||||
|
||||
std::string prefixed_desc = "Window " + std::to_string(window_index) + ", Screen " + std::to_string(screen_index) + ", " + description;
|
||||
if (slider_count > 1)
|
||||
{
|
||||
int min[3];
|
||||
@ -101,16 +102,16 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
desc = "Window " + std::to_string(window_index) + ", " + description + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "X" : "Red");
|
||||
desc = prefixed_desc + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "X" : "Red");
|
||||
break;
|
||||
case 1:
|
||||
desc = "Window " + std::to_string(window_index) + ", " + description + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Y" : "Green");
|
||||
desc = prefixed_desc + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Y" : "Green");
|
||||
break;
|
||||
case 2:
|
||||
desc = "Window " + std::to_string(window_index) + ", " + description + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Invalid" : "Blue");
|
||||
desc = prefixed_desc + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Invalid" : "Blue");
|
||||
break;
|
||||
default:
|
||||
desc = "Window " + std::to_string(window_index) + ", " + description + "Invalid";
|
||||
desc = prefixed_desc + "Invalid";
|
||||
break;
|
||||
}
|
||||
sliders.push_back(new bgfx_slider(machine, full_name, min[index], defaults[index], max[index], step, type, screen_type, scale, format, desc, strings));
|
||||
@ -121,7 +122,7 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
||||
int min = get_int(value, "min", 0);
|
||||
int def = get_int(value, "default", 0);
|
||||
int max = get_int(value, "max", 100);
|
||||
sliders.push_back(new bgfx_slider(machine, name + "0", min, def, max, step, type, screen_type, scale, format, "Window " + std::to_string(window_index) + ", " + description, strings));
|
||||
sliders.push_back(new bgfx_slider(machine, name + "0", min, def, max, step, type, screen_type, scale, format, prefixed_desc, strings));
|
||||
}
|
||||
return sliders;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class running_machine;
|
||||
class slider_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static std::vector<bgfx_slider*> read_from_value(const Value& value, std::string prefix, running_machine& machine, uint32_t window_index);
|
||||
static std::vector<bgfx_slider*> read_from_value(const Value& value, std::string prefix, running_machine& machine, uint32_t window_index, uint32_t screen_index);
|
||||
|
||||
private:
|
||||
static bool get_values(const Value& value, std::string prefix, std::string name, int* values, const int count);
|
||||
|
@ -2651,7 +2651,6 @@ void uniform::update()
|
||||
static_cast<float>(static_cast<int>(shadersys->curr_poly->get_prim_width() + 0.5f)),
|
||||
static_cast<float>(static_cast<int>(shadersys->curr_poly->get_prim_height() + 0.5f)) };
|
||||
m_shader->set_vector("QuadDims", 2, quaddims);
|
||||
printf("Quad Dims: %f, %f\n", quaddims[0], quaddims[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3099,6 +3098,10 @@ ULONG effect::release()
|
||||
|
||||
slider_state *renderer_d3d9::get_slider_list()
|
||||
{
|
||||
if (window().m_index > 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return g_slider_list;
|
||||
}
|
||||
|
||||
|
@ -212,27 +212,41 @@ int renderer_bgfx::create()
|
||||
|
||||
void renderer_bgfx::parse_screen_chains(std::string chain_str)
|
||||
{
|
||||
std::vector<std::string> chains;
|
||||
std::vector<std::vector<std::string>> chains;
|
||||
uint32_t length = chain_str.length();
|
||||
uint32_t last_start = 0;
|
||||
uint32_t win = 0;
|
||||
chains.push_back(std::vector<std::string>());
|
||||
for (uint32_t i = 0; i < length + 1; i++)
|
||||
{
|
||||
if (i == length || chain_str[i] == ',')
|
||||
if (i == length || chain_str[i] == ',' || chain_str[i] == ':')
|
||||
{
|
||||
chains.push_back(chain_str.substr(last_start, i - last_start));
|
||||
chains[win].push_back(chain_str.substr(last_start, i - last_start));
|
||||
last_start = i + 1;
|
||||
if (chain_str[i] == ':')
|
||||
{
|
||||
win++;
|
||||
chains.push_back(std::vector<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t index = 0; index < chains.size(); index++)
|
||||
for (win = 0; win < chains.size(); win++)
|
||||
{
|
||||
bgfx_chain* chain = m_chains->chain(chains[index], window().machine(), index);
|
||||
if (chain == nullptr)
|
||||
m_screen_chains.push_back(std::vector<bgfx_chain*>());
|
||||
if (win != window().m_index)
|
||||
{
|
||||
chains.clear();
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
for (uint32_t screen = 0; screen < chains[win].size(); screen++)
|
||||
{
|
||||
bgfx_chain* chain = m_chains->chain(chains[win][screen], window().machine(), win, screen);
|
||||
if (chain == nullptr) {
|
||||
chains.clear();
|
||||
return;
|
||||
}
|
||||
m_screen_chains[win].push_back(chain);
|
||||
}
|
||||
m_screen_chains.push_back(chain);
|
||||
}
|
||||
}
|
||||
|
||||
@ -759,7 +773,7 @@ const bgfx::Memory* renderer_bgfx::mame_texture_data_to_bgfx_texture_data(UINT32
|
||||
|
||||
int renderer_bgfx::handle_screen_chains()
|
||||
{
|
||||
if (m_screen_chains.size() == 0)
|
||||
if (m_screen_chains.size() <= window().m_index || m_screen_chains[window().m_index].size() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -802,13 +816,13 @@ int renderer_bgfx::handle_screen_chains()
|
||||
|
||||
bgfx_chain* renderer_bgfx::screen_chain(int32_t screen)
|
||||
{
|
||||
if (screen >= m_screen_chains.size())
|
||||
if (screen >= m_screen_chains[window().m_index].size())
|
||||
{
|
||||
return m_screen_chains[m_screen_chains.size() - 1];
|
||||
return m_screen_chains[window().m_index][m_screen_chains.size() - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_screen_chains[screen];
|
||||
return m_screen_chains[window().m_index][screen];
|
||||
}
|
||||
}
|
||||
|
||||
@ -975,7 +989,7 @@ renderer_bgfx::buffer_status renderer_bgfx::buffer_primitives(int view, bool atl
|
||||
return BUFFER_PRE_FLUSH;
|
||||
}
|
||||
|
||||
if (PRIMFLAG_GET_SCREENTEX((*prim)->flags) && m_screen_chains.size() > 0)
|
||||
if (PRIMFLAG_GET_SCREENTEX((*prim)->flags) && m_screen_chains.size() > window().m_index && m_screen_chains[window().m_index].size() > 0)
|
||||
{
|
||||
render_post_screen_quad(view, *prim, buffer, screen);
|
||||
return BUFFER_SCREEN;
|
||||
@ -1195,26 +1209,29 @@ void renderer_bgfx::allocate_buffer(render_primitive *prim, UINT32 blend, bgfx::
|
||||
|
||||
slider_state* renderer_bgfx::get_slider_list()
|
||||
{
|
||||
if (m_screen_chains.size() == 0)
|
||||
if (m_screen_chains.size() <= window().m_index || m_screen_chains[window().m_index].size() == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
slider_state *listhead = nullptr;
|
||||
slider_state **tailptr = &listhead;
|
||||
for (bgfx_chain* chain : m_screen_chains)
|
||||
for (std::vector<bgfx_chain*> screen : m_screen_chains)
|
||||
{
|
||||
std::vector<bgfx_slider*> sliders = chain->sliders();
|
||||
for (bgfx_slider* slider : sliders)
|
||||
for (bgfx_chain* chain : screen)
|
||||
{
|
||||
if (*tailptr == nullptr)
|
||||
std::vector<bgfx_slider*> sliders = chain->sliders();
|
||||
for (bgfx_slider* slider : sliders)
|
||||
{
|
||||
*tailptr = slider->core_slider();
|
||||
}
|
||||
else
|
||||
{
|
||||
(*tailptr)->next = slider->core_slider();
|
||||
tailptr = &(*tailptr)->next;
|
||||
if (*tailptr == nullptr)
|
||||
{
|
||||
*tailptr = slider->core_slider();
|
||||
}
|
||||
else
|
||||
{
|
||||
(*tailptr)->next = slider->core_slider();
|
||||
tailptr = &(*tailptr)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ private:
|
||||
|
||||
bgfx_effect* m_gui_effect[4];
|
||||
bgfx_effect* m_screen_effect[4];
|
||||
std::vector<bgfx_chain*> m_screen_chains;
|
||||
std::vector<std::vector<bgfx_chain*>> m_screen_chains;
|
||||
|
||||
std::map<UINT32, rectangle_packer::packed_rectangle> m_hash_to_entry;
|
||||
std::vector<rectangle_packer::packable_rectangle> m_texinfo;
|
||||
|
@ -272,14 +272,33 @@ int windows_osd_interface::window_count()
|
||||
|
||||
void windows_osd_interface::build_slider_list()
|
||||
{
|
||||
// FIXME: take all sliders from all windows without concatenate them by slider_state->next
|
||||
|
||||
m_sliders = nullptr;
|
||||
slider_state* full_list = nullptr;
|
||||
slider_state* curr = nullptr;
|
||||
for (win_window_info *window = win_window_list; window != nullptr; window = window->m_next)
|
||||
{
|
||||
// take the sliders of the first window
|
||||
m_sliders = window->m_renderer->get_slider_list();
|
||||
return;
|
||||
slider_state* window_sliders = window->m_renderer->get_slider_list();
|
||||
if (window_sliders == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (full_list == nullptr)
|
||||
{
|
||||
full_list = curr = window_sliders;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr->next = window_sliders;
|
||||
}
|
||||
|
||||
while (curr->next != nullptr) {
|
||||
curr = curr->next;
|
||||
}
|
||||
}
|
||||
|
||||
m_sliders = full_list;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
|
Loading…
Reference in New Issue
Block a user