mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
Fix lots of issues with bgfx
This commit is contained in:
parent
1226b243a2
commit
825d575195
@ -4,9 +4,6 @@
|
|||||||
{ "name": "temp",
|
{ "name": "temp",
|
||||||
"mode": "guest",
|
"mode": "guest",
|
||||||
"bilinear": true
|
"bilinear": true
|
||||||
},
|
|
||||||
{ "name": "screen",
|
|
||||||
"mode": "native"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"passes": [
|
"passes": [
|
||||||
@ -22,8 +19,7 @@
|
|||||||
"input": [
|
"input": [
|
||||||
{ "sampler": "s_tex", "texture": "temp" }
|
{ "sampler": "s_tex", "texture": "temp" }
|
||||||
],
|
],
|
||||||
"output": "screen"
|
"output": "output"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"output": "screen"
|
|
||||||
}
|
}
|
@ -71,15 +71,6 @@
|
|||||||
"mode": "guest",
|
"mode": "guest",
|
||||||
"prescale": true,
|
"prescale": true,
|
||||||
"doublebuffer": true
|
"doublebuffer": true
|
||||||
},
|
|
||||||
{ "name": "previous",
|
|
||||||
"mode": "guest",
|
|
||||||
"prescale": true,
|
|
||||||
"doublebuffer": true
|
|
||||||
},
|
|
||||||
{ "name": "screen",
|
|
||||||
"mode": "native",
|
|
||||||
"doublebuffer": true
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"passes": [
|
"passes": [
|
||||||
@ -307,8 +298,7 @@
|
|||||||
"input": [
|
"input": [
|
||||||
{ "sampler": "s_tex", "texture": "internal" }
|
{ "sampler": "s_tex", "texture": "internal" }
|
||||||
],
|
],
|
||||||
"output": "screen"
|
"output": "output"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"output": "screen"
|
|
||||||
}
|
}
|
@ -4,9 +4,6 @@
|
|||||||
{ "name": "temp",
|
{ "name": "temp",
|
||||||
"mode": "guest",
|
"mode": "guest",
|
||||||
"bilinear": false
|
"bilinear": false
|
||||||
},
|
|
||||||
{ "name": "screen",
|
|
||||||
"mode": "native"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"passes": [
|
"passes": [
|
||||||
@ -22,8 +19,7 @@
|
|||||||
"input": [
|
"input": [
|
||||||
{ "sampler": "s_tex", "texture": "temp" }
|
{ "sampler": "s_tex", "texture": "temp" }
|
||||||
],
|
],
|
||||||
"output": "screen"
|
"output": "output"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"output": "screen"
|
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -146,6 +146,7 @@ function osdmodulesbuild()
|
|||||||
MAME_DIR .. "src/osd/modules/render/bgfx/suppressor.cpp",
|
MAME_DIR .. "src/osd/modules/render/bgfx/suppressor.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/render/bgfx/suppressorreader.cpp",
|
MAME_DIR .. "src/osd/modules/render/bgfx/suppressorreader.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/render/bgfx/target.cpp",
|
MAME_DIR .. "src/osd/modules/render/bgfx/target.cpp",
|
||||||
|
MAME_DIR .. "src/osd/modules/render/bgfx/targetreader.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/render/bgfx/targetmanager.cpp",
|
MAME_DIR .. "src/osd/modules/render/bgfx/targetmanager.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/render/bgfx/texture.cpp",
|
MAME_DIR .. "src/osd/modules/render/bgfx/texture.cpp",
|
||||||
MAME_DIR .. "src/osd/modules/render/bgfx/texturemanager.cpp",
|
MAME_DIR .. "src/osd/modules/render/bgfx/texturemanager.cpp",
|
||||||
|
@ -146,8 +146,8 @@ const options_entry osd_options::s_option_entries[] =
|
|||||||
{ OSDOPTION_BGFX_DEBUG, "0", OPTION_BOOLEAN, "enable BGFX debugging statistics" },
|
{ OSDOPTION_BGFX_DEBUG, "0", OPTION_BOOLEAN, "enable BGFX debugging statistics" },
|
||||||
{ OSDOPTION_BGFX_SCREEN_CHAIN, "default", OPTION_STRING, "screen chain JSON file to use" },
|
{ OSDOPTION_BGFX_SCREEN_CHAIN, "default", OPTION_STRING, "screen chain JSON file to use" },
|
||||||
{ OSDOPTION_BGFX_SHADOW_MASK, "shadow-mask.png", OPTION_STRING, "shadow mask texture name" },
|
{ OSDOPTION_BGFX_SHADOW_MASK, "shadow-mask.png", OPTION_STRING, "shadow mask texture name" },
|
||||||
{ OSDOPTION_BGFX_PRESCALE_X, "1", OPTION_INTEGER, "x prescale" },
|
{ OSDOPTION_BGFX_PRESCALE_X, "2", OPTION_INTEGER, "x prescale" },
|
||||||
{ OSDOPTION_BGFX_PRESCALE_Y, "1", OPTION_INTEGER, "y prescale" },
|
{ OSDOPTION_BGFX_PRESCALE_Y, "2", OPTION_INTEGER, "y prescale" },
|
||||||
|
|
||||||
// End of list
|
// End of list
|
||||||
{ nullptr }
|
{ nullptr }
|
||||||
|
@ -19,13 +19,12 @@
|
|||||||
|
|
||||||
#include "chain.h"
|
#include "chain.h"
|
||||||
|
|
||||||
bgfx_chain::bgfx_chain(std::string name, std::string author, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries, std::string output)
|
bgfx_chain::bgfx_chain(std::string name, std::string author, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries)
|
||||||
: m_name(name)
|
: m_name(name)
|
||||||
, m_author(author)
|
, m_author(author)
|
||||||
, m_sliders(sliders)
|
, m_sliders(sliders)
|
||||||
, m_params(params)
|
, m_params(params)
|
||||||
, m_entries(entries)
|
, m_entries(entries)
|
||||||
, m_output(output)
|
|
||||||
, m_current_time(0)
|
, m_current_time(0)
|
||||||
{
|
{
|
||||||
for (bgfx_slider* slider : m_sliders)
|
for (bgfx_slider* slider : m_sliders)
|
||||||
@ -50,7 +49,7 @@ bgfx_chain::~bgfx_chain()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgfx_chain::process(render_primitive* prim, int view, texture_manager& textures, osd_window& window, uint64_t blend)
|
void bgfx_chain::process(render_primitive* prim, int view, int screen, texture_manager& textures, osd_window& window, uint64_t blend)
|
||||||
{
|
{
|
||||||
int current_view = view;
|
int current_view = view;
|
||||||
uint16_t screen_width = window.get_size().width();
|
uint16_t screen_width = window.get_size().width();
|
||||||
@ -67,7 +66,7 @@ void bgfx_chain::process(render_primitive* prim, int view, texture_manager& text
|
|||||||
{
|
{
|
||||||
if (!entry->skip())
|
if (!entry->skip())
|
||||||
{
|
{
|
||||||
entry->submit(current_view, prim, textures, screen_width, screen_height, rotation_type, swap_xy, blend);
|
entry->submit(current_view, prim, textures, screen_width, screen_height, rotation_type, swap_xy, blend, screen);
|
||||||
current_view++;
|
current_view++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,13 @@ class osd_window;
|
|||||||
class bgfx_chain
|
class bgfx_chain
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bgfx_chain(std::string name, std::string author, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries, std::string output);
|
bgfx_chain(std::string name, std::string author, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries);
|
||||||
~bgfx_chain();
|
~bgfx_chain();
|
||||||
|
|
||||||
void process(render_primitive* prim, int view, texture_manager& textures, osd_window &window, uint64_t blend = 0L);
|
void process(render_primitive* prim, int view, int screen, texture_manager& textures, osd_window &window, uint64_t blend = 0L);
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
std::vector<bgfx_slider*>& sliders() { return m_sliders; }
|
std::vector<bgfx_slider*>& sliders() { return m_sliders; }
|
||||||
std::string output() const { return m_output; }
|
|
||||||
uint32_t applicable_passes();
|
uint32_t applicable_passes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -43,7 +42,6 @@ private:
|
|||||||
std::vector<bgfx_parameter*> m_params;
|
std::vector<bgfx_parameter*> m_params;
|
||||||
std::vector<bgfx_chain_entry*> m_entries;
|
std::vector<bgfx_chain_entry*> m_entries;
|
||||||
std::map<std::string, bgfx_slider*> m_slider_map;
|
std::map<std::string, bgfx_slider*> m_slider_map;
|
||||||
std::string m_output;
|
|
||||||
int64_t m_current_time;
|
int64_t m_current_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,18 +44,18 @@ bgfx_chain_entry::~bgfx_chain_entry()
|
|||||||
m_uniforms.clear();
|
m_uniforms.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgfx_chain_entry::submit(int view, render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, uint64_t blend)
|
void bgfx_chain_entry::submit(int view, render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, uint64_t blend, int32_t screen)
|
||||||
{
|
{
|
||||||
bgfx::setViewSeq(view, true);
|
bgfx::setViewSeq(view, true);
|
||||||
|
|
||||||
if (!setup_view(view, screen_width, screen_height))
|
if (!setup_view(view, screen_width, screen_height, screen))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (bgfx_input_pair input : m_inputs)
|
for (bgfx_input_pair input : m_inputs)
|
||||||
{
|
{
|
||||||
input.bind(m_effect, textures);
|
input.bind(m_effect, textures, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
bgfx::TransientVertexBuffer buffer;
|
bgfx::TransientVertexBuffer buffer;
|
||||||
@ -74,9 +74,14 @@ void bgfx_chain_entry::submit(int view, render_primitive* prim, texture_manager&
|
|||||||
|
|
||||||
m_effect->submit(view, blend);
|
m_effect->submit(view, blend);
|
||||||
|
|
||||||
if (m_targets.target(m_output) != nullptr)
|
std::string output_name = m_output;
|
||||||
|
if (output_name == "output" || output_name == "previous")
|
||||||
{
|
{
|
||||||
m_targets.target(m_output)->page_flip();
|
output_name = output_name + std::to_string(screen);
|
||||||
|
}
|
||||||
|
if (m_targets.target(output_name) != nullptr)
|
||||||
|
{
|
||||||
|
m_targets.target(output_name)->page_flip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,14 +148,19 @@ void bgfx_chain_entry::setup_auto_uniforms(render_primitive* prim, texture_manag
|
|||||||
setup_swapxy_uniform(swap_xy);
|
setup_swapxy_uniform(swap_xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t screen_height)
|
bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen)
|
||||||
{
|
{
|
||||||
bgfx::FrameBufferHandle handle = BGFX_INVALID_HANDLE;
|
bgfx::FrameBufferHandle handle = BGFX_INVALID_HANDLE;
|
||||||
uint16_t width = screen_width;
|
uint16_t width = screen_width;
|
||||||
uint16_t height = screen_height;
|
uint16_t height = screen_height;
|
||||||
if (m_targets.target(m_output) != nullptr)
|
std::string output_name = m_output;
|
||||||
|
if (output_name == "output" || output_name == "previous")
|
||||||
{
|
{
|
||||||
bgfx_target* output = m_targets.target(m_output);
|
output_name = output_name + std::to_string(screen);
|
||||||
|
}
|
||||||
|
if (m_targets.target(output_name) != nullptr)
|
||||||
|
{
|
||||||
|
bgfx_target* output = m_targets.target(output_name);
|
||||||
if (output->width() == 0)
|
if (output->width() == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -164,7 +174,7 @@ bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t scre
|
|||||||
bgfx::setViewRect(view, 0, 0, width, height);
|
bgfx::setViewRect(view, 0, 0, width, height);
|
||||||
|
|
||||||
float projMat[16];
|
float projMat[16];
|
||||||
bx::mtxOrtho(projMat, 0.0f, screen_width, screen_height, 0.0f, 0.0f, 100.0f);
|
bx::mtxOrtho(projMat, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
|
||||||
bgfx::setViewTransform(view, nullptr, projMat);
|
bgfx::setViewTransform(view, nullptr, projMat);
|
||||||
|
|
||||||
bgfx::setViewClear(view, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x000000ff, 1.0f, 0);
|
bgfx::setViewClear(view, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x000000ff, 1.0f, 0);
|
||||||
@ -184,8 +194,8 @@ void bgfx_chain_entry::put_screen_buffer(render_primitive* prim, bgfx::Transient
|
|||||||
|
|
||||||
ScreenVertex* vertex = reinterpret_cast<ScreenVertex*>(buffer->data);
|
ScreenVertex* vertex = reinterpret_cast<ScreenVertex*>(buffer->data);
|
||||||
|
|
||||||
float x[4] = { prim->bounds.x0, prim->bounds.x1, prim->bounds.x0, prim->bounds.x1 };
|
float x[4] = { 0, 1, 0, 1 };
|
||||||
float y[4] = { prim->bounds.y0, prim->bounds.y0, prim->bounds.y1, prim->bounds.y1 };
|
float y[4] = { 0, 0, 1, 1 };
|
||||||
float u[4] = { 0, 1, 0, 1 };
|
float u[4] = { 0, 1, 0, 1 };
|
||||||
float v[4] = { 0, 0, 1, 1 };
|
float v[4] = { 0, 0, 1, 1 };
|
||||||
|
|
||||||
|
@ -36,11 +36,10 @@ public:
|
|||||||
bgfx_chain_entry(std::string name, bgfx_effect* effect, std::vector<bgfx_suppressor*> suppressors, std::vector<bgfx_input_pair> inputs, std::vector<bgfx_entry_uniform*> uniforms, target_manager& targets, std::string output);
|
bgfx_chain_entry(std::string name, bgfx_effect* effect, std::vector<bgfx_suppressor*> suppressors, std::vector<bgfx_input_pair> inputs, std::vector<bgfx_entry_uniform*> uniforms, target_manager& targets, std::string output);
|
||||||
~bgfx_chain_entry();
|
~bgfx_chain_entry();
|
||||||
|
|
||||||
void submit(int view, render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, uint64_t blend);
|
void submit(int view, render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, uint64_t blend, int32_t screen);
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
std::string name() const { return m_name; }
|
std::string name() const { return m_name; }
|
||||||
bgfx_target* target() const { return m_targets.target(m_output); }
|
|
||||||
bool skip();
|
bool skip();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -50,7 +49,7 @@ private:
|
|||||||
void setup_rotationtype_uniform(uint32_t rotation_type);
|
void setup_rotationtype_uniform(uint32_t rotation_type);
|
||||||
void setup_swapxy_uniform(bool swap_xy);
|
void setup_swapxy_uniform(bool swap_xy);
|
||||||
|
|
||||||
bool setup_view(int view, uint16_t screen_width, uint16_t screen_height);
|
bool setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen);
|
||||||
void put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer);
|
void put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer);
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
@ -29,7 +29,11 @@
|
|||||||
|
|
||||||
bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::string prefix, osd_options& options, texture_manager& textures, target_manager& targets, effect_manager& effects, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params)
|
bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::string prefix, osd_options& options, texture_manager& textures, target_manager& targets, effect_manager& effects, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
printf("Failed validation\n");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bgfx_effect* effect = effects.effect(value["effect"].GetString());
|
bgfx_effect* effect = effects.effect(value["effect"].GetString());
|
||||||
std::string name = value["name"].GetString();
|
std::string name = value["name"].GetString();
|
||||||
@ -37,14 +41,13 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
|||||||
std::vector<bgfx_input_pair> inputs;
|
std::vector<bgfx_input_pair> inputs;
|
||||||
if (value.HasMember("input"))
|
if (value.HasMember("input"))
|
||||||
{
|
{
|
||||||
READER_ASSERT(value["input"].IsArray(), (prefix + "Chain entry '" + name + "': value 'input' must be an array\n").c_str());
|
|
||||||
const Value& input_array = value["input"];
|
const Value& input_array = value["input"];
|
||||||
for (UINT32 i = 0; i < input_array.Size(); i++)
|
for (UINT32 i = 0; i < input_array.Size(); i++)
|
||||||
{
|
{
|
||||||
READER_ASSERT(input_array[i].HasMember("sampler"), (prefix + "input[" + std::to_string(i) + ": Must have string value 'sampler' (what sampler are we binding to?)\n").c_str());
|
if (!READER_CHECK(input_array[i].HasMember("sampler"), (prefix + "input[" + std::to_string(i) + ": Must have string value 'sampler' (what sampler are we binding to?)\n").c_str())) return nullptr;
|
||||||
READER_ASSERT(input_array[i]["sampler"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'sampler' must be a string\n").c_str());
|
if (!READER_CHECK(input_array[i]["sampler"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'sampler' must be a string\n").c_str())) return nullptr;
|
||||||
READER_ASSERT(input_array[i].HasMember("texture"), (prefix + "input[" + std::to_string(i) + ": Must have string value 'texture' (what texture are we using?)\n").c_str());
|
if (!READER_CHECK(input_array[i].HasMember("texture"), (prefix + "input[" + std::to_string(i) + ": Must have string value 'texture' (what texture are we using?)\n").c_str())) return nullptr;
|
||||||
READER_ASSERT(input_array[i]["texture"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'texture' must be a string\n").c_str());
|
if (!READER_CHECK(input_array[i]["texture"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'texture' must be a string\n").c_str())) return nullptr;
|
||||||
std::string sampler = input_array[i]["sampler"].GetString();
|
std::string sampler = input_array[i]["sampler"].GetString();
|
||||||
std::string texture = input_array[i]["texture"].GetString();
|
std::string texture = input_array[i]["texture"].GetString();
|
||||||
inputs.push_back(bgfx_input_pair(i, sampler, texture));
|
inputs.push_back(bgfx_input_pair(i, sampler, texture));
|
||||||
@ -54,55 +57,69 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
|||||||
std::vector<bgfx_entry_uniform*> uniforms;
|
std::vector<bgfx_entry_uniform*> uniforms;
|
||||||
if (value.HasMember("uniforms"))
|
if (value.HasMember("uniforms"))
|
||||||
{
|
{
|
||||||
READER_ASSERT(value["uniforms"].IsArray(), (prefix + "Chain entry '" + name + "': value 'uniforms' must be an array\n").c_str());
|
|
||||||
const Value& uniform_array = value["uniforms"];
|
const Value& uniform_array = value["uniforms"];
|
||||||
for (UINT32 i = 0; i < uniform_array.Size(); i++)
|
for (UINT32 i = 0; i < uniform_array.Size(); i++)
|
||||||
{
|
{
|
||||||
uniforms.push_back(entry_uniform_reader::read_from_value(uniform_array[i], prefix + "uniforms[" + std::to_string(i) + "]: ", effect, sliders, params));
|
bgfx_entry_uniform* uniform = entry_uniform_reader::read_from_value(uniform_array[i], prefix + "uniforms[" + std::to_string(i) + "]: ", effect, sliders, params);
|
||||||
|
if (uniform == nullptr)
|
||||||
|
{
|
||||||
|
for (bgfx_entry_uniform* existing_uniform : uniforms) delete existing_uniform;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
uniforms.push_back(uniform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<bgfx_suppressor*> suppressors;
|
std::vector<bgfx_suppressor*> suppressors;
|
||||||
if (value.HasMember("disablewhen"))
|
if (value.HasMember("disablewhen"))
|
||||||
{
|
{
|
||||||
READER_ASSERT(value["disablewhen"].IsArray(), (prefix + "Chain entry '" + name + "': value 'disablewhen' must be an array\n").c_str());
|
|
||||||
const Value& suppressor_array = value["disablewhen"];
|
const Value& suppressor_array = value["disablewhen"];
|
||||||
for (UINT32 i = 0; i < suppressor_array.Size(); i++)
|
for (UINT32 i = 0; i < suppressor_array.Size(); i++)
|
||||||
{
|
{
|
||||||
suppressors.push_back(suppressor_reader::read_from_value(suppressor_array[i], prefix, sliders));
|
bgfx_suppressor* suppressor = suppressor_reader::read_from_value(suppressor_array[i], prefix, sliders);
|
||||||
|
if (suppressor == nullptr)
|
||||||
|
{
|
||||||
|
for (bgfx_entry_uniform* uniform : uniforms) delete uniform;
|
||||||
|
for (bgfx_suppressor* existing_suppressor : suppressors) delete existing_suppressor;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
suppressors.push_back(suppressor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.HasMember("textures"))
|
if (value.HasMember("textures"))
|
||||||
{
|
{
|
||||||
READER_ASSERT(value["textures"].IsArray(), (prefix + "Chain entry '" + name + "': value 'textures' must be an array\n").c_str());
|
|
||||||
const Value& texture_array = value["textures"];
|
const Value& texture_array = value["textures"];
|
||||||
for (UINT32 i = 0; i < texture_array.Size(); i++)
|
for (UINT32 i = 0; i < texture_array.Size(); i++)
|
||||||
{
|
{
|
||||||
std::string texture_path = std::string(options.bgfx_path()) + "/artwork/";
|
std::string texture_path = std::string(options.bgfx_path()) + "/artwork/";
|
||||||
|
if (!READER_CHECK(texture_array[i].IsString(), (prefix + "textures[" + std::to_string(i) + "]: Value must be a string\n").c_str()))
|
||||||
|
{
|
||||||
|
for (bgfx_entry_uniform* uniform : uniforms) delete uniform;
|
||||||
|
for (bgfx_suppressor* suppressor : suppressors) delete suppressor;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
std::string texture_name = texture_array[i].GetString();
|
std::string texture_name = texture_array[i].GetString();
|
||||||
|
|
||||||
textures.create_png_texture(texture_path, texture_name, texture_name);
|
textures.create_png_texture(texture_path, texture_name, texture_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string output_name = value["output"].GetString();
|
std::string output = value["output"].GetString();
|
||||||
if (output_name != std::string("backbuffer"))
|
return new bgfx_chain_entry(name, effect, suppressors, inputs, uniforms, targets, output);
|
||||||
{
|
|
||||||
return new bgfx_chain_entry(name, effect, suppressors, inputs, uniforms, targets, output_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new bgfx_chain_entry(name, effect, suppressors, inputs, uniforms, targets, "none");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void chain_entry_reader::validate_parameters(const Value& value, std::string prefix)
|
bool chain_entry_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("effect"), (prefix + "Must have string value 'effect' (what effect does this entry use?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("effect"), (prefix + "Must have string value 'effect' (what effect does this entry use?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["effect"].IsString(), (prefix + "Value 'effect' must be a string\n").c_str());
|
if (!READER_CHECK(value["effect"].IsString(), (prefix + "Value 'effect' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("name"), (prefix + "Must have string value 'effect' (what effect does this entry use?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'effect' (what effect does this entry use?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str());
|
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("output"), (prefix + "Must have string value 'output' (what target contains the result of this entry?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("output"), (prefix + "Must have string value 'offset' (what target are we rendering to?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["output"].IsString(), (prefix + "Value 'output' must be a string\n").c_str());
|
if (!READER_CHECK(value["output"].IsString(), (prefix + "Value 'output' must be a string\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("input") || value["input"].IsArray(), (prefix + "Value 'input' must be an array\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("uniforms") || value["uniforms"].IsArray(), (prefix + "Value 'uniforms' must be an array\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("disablewhen") || value["disablewhen"].IsArray(), (prefix + "Value 'disablewhen' must be an array\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("textures") || value["textures"].IsArray(), (prefix + "Value 'textures' must be an array\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ public:
|
|||||||
static bgfx_chain_entry* read_from_value(const Value& value, std::string prefix, osd_options& options, texture_manager& textures, target_manager& targets, effect_manager& effects, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params);
|
static bgfx_chain_entry* read_from_value(const Value& value, std::string prefix, osd_options& options, texture_manager& textures, target_manager& targets, effect_manager& effects, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_CHAIN_ENTRY_READER__
|
#endif // __DRAWBGFX_CHAIN_ENTRY_READER__
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
|
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
|
#include <rapidjson/error/en.h>
|
||||||
|
|
||||||
#include <bx/readerwriter.h>
|
#include <bx/readerwriter.h>
|
||||||
#include <bx/crtimpl.h>
|
#include <bx/crtimpl.h>
|
||||||
@ -51,7 +52,11 @@ bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine
|
|||||||
std::string path = std::string(m_options.bgfx_path()) + "/chains/" + name;
|
std::string path = std::string(m_options.bgfx_path()) + "/chains/" + name;
|
||||||
|
|
||||||
bx::CrtFileReader reader;
|
bx::CrtFileReader reader;
|
||||||
bx::open(&reader, path.c_str());
|
if (!bx::open(&reader, path.c_str()))
|
||||||
|
{
|
||||||
|
printf("Unable to open chain file %s, falling back to no post processing\n", path.c_str());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t size(bx::getSize(&reader));
|
int32_t size(bx::getSize(&reader));
|
||||||
|
|
||||||
@ -62,8 +67,23 @@ bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine
|
|||||||
|
|
||||||
Document document;
|
Document document;
|
||||||
document.Parse<0>(data);
|
document.Parse<0>(data);
|
||||||
|
|
||||||
|
if (document.HasParseError())
|
||||||
|
{
|
||||||
|
std::string error(GetParseError_En(document.GetParseError()));
|
||||||
|
printf("Unable to parse chain %s. Errors returned:\n", path.c_str());
|
||||||
|
printf("%s\n", error.c_str());
|
||||||
|
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, m_textures, m_targets, m_effects, m_width, m_height);
|
||||||
|
|
||||||
|
if (chain == nullptr)
|
||||||
|
{
|
||||||
|
printf("Unable to load chain %s, falling back to no post processing\n", path.c_str());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
m_chains[name + std::to_string(window_index)] = chain;
|
m_chains[name + std::to_string(window_index)] = chain;
|
||||||
|
|
||||||
return chain;
|
return chain;
|
||||||
|
@ -13,25 +13,23 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include <modules/lib/osdobj_common.h>
|
#include <modules/lib/osdobj_common.h>
|
||||||
|
|
||||||
|
#include "chainreader.h"
|
||||||
|
|
||||||
#include "chain.h"
|
#include "chain.h"
|
||||||
#include "sliderreader.h"
|
#include "sliderreader.h"
|
||||||
#include "paramreader.h"
|
#include "paramreader.h"
|
||||||
#include "chainentryreader.h"
|
#include "chainentryreader.h"
|
||||||
|
#include "targetreader.h"
|
||||||
#include "targetmanager.h"
|
#include "targetmanager.h"
|
||||||
#include "chainreader.h"
|
|
||||||
#include "target.h"
|
|
||||||
#include "slider.h"
|
#include "slider.h"
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
|
|
||||||
const chain_reader::string_to_enum chain_reader::STYLE_NAMES[chain_reader::STYLE_COUNT] = {
|
|
||||||
{ "guest", TARGET_STYLE_GUEST },
|
|
||||||
{ "native", TARGET_STYLE_NATIVE },
|
|
||||||
{ "custom", TARGET_STYLE_CUSTOM }
|
|
||||||
};
|
|
||||||
|
|
||||||
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, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = value["name"].GetString();
|
std::string name = value["name"].GetString();
|
||||||
std::string author = value["author"].GetString();
|
std::string author = value["author"].GetString();
|
||||||
@ -44,6 +42,10 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix
|
|||||||
for (UINT32 i = 0; i < slider_array.Size(); i++)
|
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);
|
||||||
|
if (expanded_sliders.size() == 0)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
for (bgfx_slider* slider : expanded_sliders)
|
for (bgfx_slider* slider : expanded_sliders)
|
||||||
{
|
{
|
||||||
sliders.push_back(slider);
|
sliders.push_back(slider);
|
||||||
@ -62,11 +64,15 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix
|
|||||||
std::vector<bgfx_parameter*> parameters;
|
std::vector<bgfx_parameter*> parameters;
|
||||||
if (value.HasMember("parameters"))
|
if (value.HasMember("parameters"))
|
||||||
{
|
{
|
||||||
READER_ASSERT(value["parameters"].IsArray(), (prefix + "Value 'parameters' must be an array\n").c_str());
|
|
||||||
const Value& param_array = value["parameters"];
|
const Value& param_array = value["parameters"];
|
||||||
for (UINT32 i = 0; i < param_array.Size(); i++)
|
for (UINT32 i = 0; i < param_array.Size(); i++)
|
||||||
{
|
{
|
||||||
parameters.push_back(parameter_reader::read_from_value(param_array[i], prefix + "parameters[" + std::to_string(i) + "]; ", window_index));
|
bgfx_parameter* parameter = parameter_reader::read_from_value(param_array[i], prefix + "parameters[" + std::to_string(i) + "]; ", window_index);
|
||||||
|
if (parameter == nullptr)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
parameters.push_back(parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,56 +86,14 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix
|
|||||||
// Create targets
|
// Create targets
|
||||||
if (value.HasMember("targets"))
|
if (value.HasMember("targets"))
|
||||||
{
|
{
|
||||||
READER_ASSERT(value["targets"].IsArray(), (prefix + "Value 'targets' must be an array\n").c_str());
|
|
||||||
const Value& target_array = value["targets"];
|
const Value& target_array = value["targets"];
|
||||||
// TODO: Move into its own reader
|
// TODO: Move into its own reader
|
||||||
for (UINT32 i = 0; i < target_array.Size(); i++)
|
for (UINT32 i = 0; i < target_array.Size(); i++)
|
||||||
{
|
{
|
||||||
READER_ASSERT(target_array[i].HasMember("name"), (prefix + "targets[" + std::to_string(i) + "]: Must have string value 'name'\n").c_str());
|
if (!target_reader::read_from_value(target_array[i], prefix + "targets[" + std::to_string(i) + "]: ", targets, options, screen_width, screen_height))
|
||||||
READER_ASSERT(target_array[i]["name"].IsString(), (prefix + "targets[" + std::to_string(i) + "]: Value 'name' must be a string\n").c_str());
|
|
||||||
READER_ASSERT(target_array[i].HasMember("mode"), (prefix + "targets[" + std::to_string(i) + "]: Must have string enum 'mode'\n").c_str());
|
|
||||||
READER_ASSERT(target_array[i]["mode"].IsString(), (prefix + "targets[" + std::to_string(i) + "]: Value 'mode' must be a string (what screens does this apply to?)\n").c_str());
|
|
||||||
READER_ASSERT(!target_array[i].HasMember("bilinear") || target_array[i]["bilinear"].IsBool(), (prefix + "targets[" + std::to_string(i) + "]: Value 'bilinear' must be a boolean\n").c_str());
|
|
||||||
READER_ASSERT(!target_array[i].HasMember("doublebuffer") || target_array[i]["doublebuffer"].IsBool(), (prefix + "targets[" + std::to_string(i) + "]: Value 'doublebuffer' must be a boolean\n").c_str());
|
|
||||||
READER_ASSERT(!target_array[i].HasMember("prescale") || target_array[i]["prescale"].IsBool(), (prefix + "targets[" + std::to_string(i) + "]: Value 'prescale' must be a boolean\n").c_str());
|
|
||||||
|
|
||||||
std::string target_name = target_array[i]["name"].GetString();
|
|
||||||
uint32_t mode = uint32_t(get_enum_from_value(target_array[i], "mode", TARGET_STYLE_NATIVE, STYLE_NAMES, STYLE_COUNT));
|
|
||||||
bool bilinear = get_bool(target_array[i], "bilinear", true);
|
|
||||||
bool double_buffer = get_bool(target_array[i], "doublebuffer", true);
|
|
||||||
bool prescale = get_bool(target_array[i], "prescale", false);
|
|
||||||
|
|
||||||
uint16_t width = 0;
|
|
||||||
uint16_t height = 0;
|
|
||||||
switch (mode)
|
|
||||||
{
|
{
|
||||||
case TARGET_STYLE_GUEST:
|
return nullptr;
|
||||||
width = targets.guest_width();
|
|
||||||
height = targets.guest_height();
|
|
||||||
break;
|
|
||||||
case TARGET_STYLE_NATIVE:
|
|
||||||
width = screen_width;
|
|
||||||
height = screen_height;
|
|
||||||
break;
|
|
||||||
case TARGET_STYLE_CUSTOM:
|
|
||||||
READER_ASSERT(target_array[i].HasMember("width"), (prefix + "Target '" + target_name + "': Must have numeric value 'width'\n").c_str());
|
|
||||||
READER_ASSERT(target_array[i]["width"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'width' must be a number\n").c_str());
|
|
||||||
READER_ASSERT(target_array[i].HasMember("height"), (prefix + "Target '" + target_name + "': Must have numeric value 'height'\n").c_str());
|
|
||||||
READER_ASSERT(target_array[i]["height"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'height' must be a number\n").c_str());
|
|
||||||
width = uint32_t(target_array[i]["width"].GetDouble());
|
|
||||||
height = uint32_t(target_array[i]["height"].GetDouble());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t prescale_x = 1;
|
|
||||||
uint32_t prescale_y = 1;
|
|
||||||
if (prescale)
|
|
||||||
{
|
|
||||||
prescale_x = options.bgfx_prescale_x();
|
|
||||||
prescale_y = options.bgfx_prescale_y();
|
|
||||||
}
|
|
||||||
|
|
||||||
targets.create_target(target_name, bgfx::TextureFormat::RGBA8, width, height, prescale_x, prescale_y, mode, double_buffer, bilinear);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,23 +104,28 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix
|
|||||||
const Value& entry_array = value["passes"];
|
const Value& entry_array = value["passes"];
|
||||||
for (UINT32 i = 0; i < entry_array.Size(); i++)
|
for (UINT32 i = 0; i < entry_array.Size(); i++)
|
||||||
{
|
{
|
||||||
entries.push_back(chain_entry_reader::read_from_value(entry_array[i], prefix + "passes[" + std::to_string(i) + "]: ", options, textures, targets, effects, slider_map, param_map));
|
bgfx_chain_entry* entry = chain_entry_reader::read_from_value(entry_array[i], prefix + "passes[" + std::to_string(i) + "]: ", options, textures, targets, effects, slider_map, param_map);
|
||||||
}
|
if (entry == nullptr)
|
||||||
}
|
|
||||||
|
|
||||||
std::string output = value["output"].GetString();
|
|
||||||
|
|
||||||
return new bgfx_chain(name, author, sliders, parameters, entries, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
void chain_reader::validate_parameters(const Value& value, std::string prefix)
|
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str());
|
return nullptr;
|
||||||
READER_ASSERT(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str());
|
}
|
||||||
READER_ASSERT(value.HasMember("author"), (prefix + "Must have string value 'author'\n").c_str());
|
entries.push_back(entry);
|
||||||
READER_ASSERT(value["author"].IsString(), (prefix + "Value 'author' must be a string\n").c_str());
|
}
|
||||||
READER_ASSERT(value.HasMember("passes"), (prefix + "Must have array value 'passes'\n").c_str());
|
}
|
||||||
READER_ASSERT(value["passes"].IsArray(), (prefix + "Value 'passes' must be an array\n").c_str());
|
|
||||||
READER_ASSERT(value.HasMember("output"), (prefix + "Must have string value 'output'\n").c_str());
|
return new bgfx_chain(name, author, sliders, parameters, entries);
|
||||||
READER_ASSERT(value["output"].IsString(), (prefix + "Value 'output' must be a string\n").c_str());
|
}
|
||||||
|
|
||||||
|
bool chain_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
|
{
|
||||||
|
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value.HasMember("author"), (prefix + "Must have string value 'author'\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["author"].IsString(), (prefix + "Value 'author' must be a string\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value.HasMember("passes"), (prefix + "Must have array value 'passes'\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["passes"].IsArray(), (prefix + "Value 'passes' must be an array\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("sliders") || value["sliders"].IsArray(), (prefix + "Value 'sliders' must be an array\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("parameters") || value["parameters"].IsArray(), (prefix + "Value 'parameters' must be an array\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("targets") || value["targets"].IsArray(), (prefix + "Value 'targets' must be an array\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,7 @@ 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, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
|
|
||||||
static const int STYLE_COUNT = 3;
|
|
||||||
static const string_to_enum STYLE_NAMES[STYLE_COUNT];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_CHAIN_READER__
|
#endif // __DRAWBGFX_CHAIN_READER__
|
||||||
|
@ -21,13 +21,13 @@ const depth_reader::string_to_enum depth_reader::FUNCTION_NAMES[depth_reader::FU
|
|||||||
{ "always", BGFX_STATE_DEPTH_TEST_ALWAYS }
|
{ "always", BGFX_STATE_DEPTH_TEST_ALWAYS }
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t depth_reader::read_from_value(const Value& value)
|
uint64_t depth_reader::read_from_value(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
uint64_t write_enable = 0;
|
uint64_t write_enable = 0;
|
||||||
if (value.HasMember("writeEnable"))
|
if (value.HasMember("writeenable"))
|
||||||
{
|
{
|
||||||
assert(value["writeEnable"].IsBool());
|
if (!READER_CHECK(value["writeenable"].IsBool(), (prefix + "Value 'writeenable' must be a boolean\n").c_str())) return 0;
|
||||||
write_enable = value["writeEnable"].GetBool() ? BGFX_STATE_DEPTH_WRITE: 0;
|
write_enable = value["writeenable"].GetBool() ? BGFX_STATE_DEPTH_WRITE: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t function = get_enum_from_value(value, "function", BGFX_STATE_DEPTH_TEST_ALWAYS, FUNCTION_NAMES, FUNCTION_COUNT);
|
uint64_t function = get_enum_from_value(value, "function", BGFX_STATE_DEPTH_TEST_ALWAYS, FUNCTION_NAMES, FUNCTION_COUNT);
|
||||||
|
@ -11,11 +11,13 @@
|
|||||||
#ifndef __DRAWBGFX_DEPTH_READER__
|
#ifndef __DRAWBGFX_DEPTH_READER__
|
||||||
#define __DRAWBGFX_DEPTH_READER__
|
#define __DRAWBGFX_DEPTH_READER__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "statereader.h"
|
#include "statereader.h"
|
||||||
|
|
||||||
class depth_reader : public state_reader {
|
class depth_reader : public state_reader {
|
||||||
public:
|
public:
|
||||||
static uint64_t read_from_value(const Value& value);
|
static uint64_t read_from_value(const Value& value, std::string prefix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int FUNCTION_COUNT = 8;
|
static const int FUNCTION_COUNT = 8;
|
||||||
|
@ -24,14 +24,17 @@
|
|||||||
|
|
||||||
bgfx_effect* effect_reader::read_from_value(const Value& value, std::string prefix, shader_manager& shaders)
|
bgfx_effect* effect_reader::read_from_value(const Value& value, std::string prefix, shader_manager& shaders)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t blend = 0;
|
uint64_t blend = 0;
|
||||||
if (value.HasMember("blend"))
|
if (value.HasMember("blend"))
|
||||||
{
|
{
|
||||||
blend = blend_reader::read_from_value(value["blend"]);
|
blend = blend_reader::read_from_value(value["blend"]);
|
||||||
}
|
}
|
||||||
uint64_t depth = depth_reader::read_from_value(value["depth"]);
|
uint64_t depth = depth_reader::read_from_value(value["depth"], prefix + "depth: ");
|
||||||
uint64_t cull = cull_reader::read_from_value(value["cull"]);
|
uint64_t cull = cull_reader::read_from_value(value["cull"]);
|
||||||
uint64_t write = write_reader::read_from_value(value["write"]);
|
uint64_t write = write_reader::read_from_value(value["write"]);
|
||||||
|
|
||||||
@ -39,7 +42,7 @@ bgfx_effect* effect_reader::read_from_value(const Value& value, std::string pref
|
|||||||
const Value& uniform_array = value["uniforms"];
|
const Value& uniform_array = value["uniforms"];
|
||||||
for (UINT32 i = 0; i < uniform_array.Size(); i++)
|
for (UINT32 i = 0; i < uniform_array.Size(); i++)
|
||||||
{
|
{
|
||||||
uniforms.push_back(uniform_reader::read_from_value(uniform_array[i]));
|
uniforms.push_back(uniform_reader::read_from_value(uniform_array[i], prefix + "uniforms[" + std::to_string(i) + "]: "));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string vertex_name(value["vertex"].GetString());
|
std::string vertex_name(value["vertex"].GetString());
|
||||||
@ -59,16 +62,17 @@ bgfx_effect* effect_reader::read_from_value(const Value& value, std::string pref
|
|||||||
return new bgfx_effect(blend | depth | cull | write, vertex_shader, fragment_shader, uniforms);
|
return new bgfx_effect(blend | depth | cull | write, vertex_shader, fragment_shader, uniforms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void effect_reader::validate_parameters(const Value& value, std::string prefix)
|
bool effect_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("depth"), (prefix + "Must have object value 'depth' (what are our Z-buffer settings?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("depth"), (prefix + "Must have object value 'depth' (what are our Z-buffer settings?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("cull"), (prefix + "Must have object value 'cull' (do we cull triangles based on winding?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("cull"), (prefix + "Must have object value 'cull' (do we cull triangles based on winding?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("write"), (prefix + "Must have object value 'write' (what are our color buffer write settings?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("write"), (prefix + "Must have object value 'write' (what are our color buffer write settings?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("vertex"), (prefix + "Must have string value 'vertex' (what is our vertex shader?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("vertex"), (prefix + "Must have string value 'vertex' (what is our vertex shader?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["vertex"].IsString(), (prefix + "Value 'vertex' must be a string\n").c_str());
|
if (!READER_CHECK(value["vertex"].IsString(), (prefix + "Value 'vertex' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("fragment") || value.HasMember("pixel"), (prefix + "Must have string value named 'fragment' or 'pixel' (what is our fragment/pixel shader?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("fragment") || value.HasMember("pixel"), (prefix + "Must have string value named 'fragment' or 'pixel' (what is our fragment/pixel shader?)\n").c_str())) return false;
|
||||||
READER_ASSERT(!value.HasMember("fragment") || value["fragment"].IsString(), (prefix + "Value 'fragment' must be a string\n").c_str());
|
if (!READER_CHECK(!value.HasMember("fragment") || value["fragment"].IsString(), (prefix + "Value 'fragment' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(!value.HasMember("pixel") || value["pixel"].IsString(), (prefix + "Value 'pixel' must be a string\n").c_str());
|
if (!READER_CHECK(!value.HasMember("pixel") || value["pixel"].IsString(), (prefix + "Value 'pixel' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("uniforms"), (prefix + "Must have array value 'uniforms' (what are our shader's parameters?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("uniforms"), (prefix + "Must have array value 'uniforms' (what are our shader's parameters?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["uniforms"].IsArray(), (prefix + "Value 'uniforms' must be an array\n").c_str());
|
if (!READER_CHECK(value["uniforms"].IsArray(), (prefix + "Value 'uniforms' must be an array\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
static bgfx_effect* read_from_value(const Value& value, std::string prefix, shader_manager& shaders);
|
static bgfx_effect* read_from_value(const Value& value, std::string prefix, shader_manager& shaders);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_EFFECT_READER__
|
#endif // __DRAWBGFX_EFFECT_READER__
|
||||||
|
@ -17,12 +17,18 @@
|
|||||||
|
|
||||||
bgfx_entry_uniform* entry_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_effect* effect, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params)
|
bgfx_entry_uniform* entry_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_effect* effect, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = value["uniform"].GetString();
|
std::string name = value["uniform"].GetString();
|
||||||
bgfx_uniform* uniform = effect->uniform(name);
|
bgfx_uniform* uniform = effect->uniform(name);
|
||||||
|
|
||||||
READER_ASSERT(uniform != nullptr, (prefix + "Uniform '" + name + " does not appear to exist\n").c_str());
|
if (!READER_CHECK(uniform != nullptr, (prefix + "Uniform '" + name + " does not appear to exist\n").c_str()))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (value.HasMember("slider"))
|
if (value.HasMember("slider"))
|
||||||
{
|
{
|
||||||
@ -36,12 +42,18 @@ bgfx_entry_uniform* entry_uniform_reader::read_from_value(const Value& value, st
|
|||||||
{
|
{
|
||||||
return param_uniform_reader::read_from_value(value, prefix, uniform, params);
|
return param_uniform_reader::read_from_value(value, prefix, uniform, params);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
READER_CHECK(false, (prefix + "Unrecognized uniform type for uniform binding " + name).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void entry_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
bool entry_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("uniform"), (prefix + "Must have string value 'uniform' (what uniform are we mapping?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("uniform"), (prefix + "Must have string value 'uniform' (what uniform are we mapping?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["uniform"].IsString(), (prefix + "Value 'effect' must be a string\n").c_str());
|
if (!READER_CHECK(value["uniform"].IsString(), (prefix + "Value 'effect' must be a string\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_effect* effect, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params);
|
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_effect* effect, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_ENTRY_UNIFORM_READER__
|
#endif // __DRAWBGFX_ENTRY_UNIFORM_READER__
|
||||||
|
@ -25,8 +25,13 @@ bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, std::string tex
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgfx_input_pair::bind(bgfx_effect *effect, texture_manager& textures) const
|
void bgfx_input_pair::bind(bgfx_effect *effect, texture_manager& textures, const int32_t screen) const
|
||||||
{
|
{
|
||||||
assert(effect->uniform(m_sampler) != nullptr);
|
assert(effect->uniform(m_sampler) != nullptr);
|
||||||
bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), textures.handle(m_texture));
|
std::string texture = m_texture;
|
||||||
|
if (m_texture == "previous")
|
||||||
|
{
|
||||||
|
texture = m_texture + std::to_string(screen);
|
||||||
|
}
|
||||||
|
bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), textures.handle(texture));
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class bgfx_input_pair
|
|||||||
public:
|
public:
|
||||||
bgfx_input_pair(int index, std::string sampler, std::string texture);
|
bgfx_input_pair(int index, std::string sampler, std::string texture);
|
||||||
|
|
||||||
void bind(bgfx_effect *effect, texture_manager& textures) const;
|
void bind(bgfx_effect *effect, texture_manager& textures, const int32_t screen) const;
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
std::string sampler() const { return m_sampler; }
|
std::string sampler() const { return m_sampler; }
|
||||||
|
@ -23,7 +23,10 @@ const parameter_reader::string_to_enum parameter_reader::TYPE_NAMES[parameter_re
|
|||||||
|
|
||||||
bgfx_parameter* parameter_reader::read_from_value(const Value& value, std::string prefix, uint32_t window_index)
|
bgfx_parameter* parameter_reader::read_from_value(const Value& value, std::string prefix, uint32_t window_index)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = value["name"].GetString();
|
std::string name = value["name"].GetString();
|
||||||
bgfx_parameter::parameter_type type = bgfx_parameter::parameter_type(get_enum_from_value(value, "type", bgfx_parameter::parameter_type::PARAM_FRAME, TYPE_NAMES, TYPE_COUNT));
|
bgfx_parameter::parameter_type type = bgfx_parameter::parameter_type(get_enum_from_value(value, "type", bgfx_parameter::parameter_type::PARAM_FRAME, TYPE_NAMES, TYPE_COUNT));
|
||||||
@ -44,18 +47,19 @@ bgfx_parameter* parameter_reader::read_from_value(const Value& value, std::strin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(false);
|
READER_CHECK(false, (prefix + "Unknown parameter type '" + std::string(value["type"].GetString()) + "'\n").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parameter_reader::validate_parameters(const Value& value, std::string prefix)
|
bool parameter_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str());
|
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str());
|
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("type"), (prefix + "Must have string value 'type'\n").c_str());
|
if (!READER_CHECK(value.HasMember("type"), (prefix + "Must have string value 'type'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["type"].IsString(), (prefix + "Value 'type' must be a string\n").c_str());
|
if (!READER_CHECK(value["type"].IsString(), (prefix + "Value 'type' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(!value.HasMember("period") || value["period"].IsNumber(), (prefix + "Value 'period' must be numeric\n").c_str());
|
if (!READER_CHECK(!value.HasMember("period") || value["period"].IsNumber(), (prefix + "Value 'period' must be numeric\n").c_str())) return false;
|
||||||
READER_ASSERT(!value.HasMember("limit") || value["limit"].IsNumber(), (prefix + "Value 'period' must be numeric\n").c_str());
|
if (!READER_CHECK(!value.HasMember("limit") || value["limit"].IsNumber(), (prefix + "Value 'period' must be numeric\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
static bgfx_parameter* read_from_value(const Value& value, std::string prefix, uint32_t window_index);
|
static bgfx_parameter* read_from_value(const Value& value, std::string prefix, uint32_t window_index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
|
|
||||||
static const int TYPE_COUNT = 3;
|
static const int TYPE_COUNT = 3;
|
||||||
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
||||||
|
@ -14,15 +14,19 @@
|
|||||||
|
|
||||||
bgfx_entry_uniform* param_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_parameter*>& params)
|
bgfx_entry_uniform* param_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_parameter*>& params)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::string parameter = value["parameter"].GetString();
|
std::string parameter = value["parameter"].GetString();
|
||||||
|
|
||||||
return new bgfx_param_uniform(uniform, params[parameter]);
|
return new bgfx_param_uniform(uniform, params[parameter]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void param_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
bool param_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("parameter"), (prefix + "Must have string value 'parameter' (what parameter is being mapped?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("parameter"), (prefix + "Must have string value 'parameter' (what parameter is being mapped?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["parameter"].IsString(), (prefix + "Value 'parameter' must be a string\n").c_str());
|
if (!READER_CHECK(value["parameter"].IsString(), (prefix + "Value 'parameter' must be a string\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_parameter*>& params);
|
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_parameter*>& params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_PARAM_UNIFORM_READER__
|
#endif // __DRAWBGFX_PARAM_UNIFORM_READER__
|
||||||
|
@ -35,7 +35,12 @@ const slider_reader::string_to_enum slider_reader::SCREEN_NAMES[slider_reader::S
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
std::vector<bgfx_slider*> sliders;
|
||||||
|
|
||||||
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return sliders;
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = value["name"].GetString();
|
std::string name = value["name"].GetString();
|
||||||
int step = value["step"].GetInt();
|
int step = value["step"].GetInt();
|
||||||
@ -48,17 +53,18 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
|||||||
std::vector<std::string> strings;
|
std::vector<std::string> strings;
|
||||||
if (value.HasMember("strings"))
|
if (value.HasMember("strings"))
|
||||||
{
|
{
|
||||||
READER_ASSERT(value["strings"].IsArray(), (prefix + "Slider '" + name + "': value 'strings' must be an array\n").c_str());
|
|
||||||
const Value& string_array = value["strings"];
|
const Value& string_array = value["strings"];
|
||||||
for (UINT32 i = 0; i < string_array.Size(); i++)
|
for (UINT32 i = 0; i < string_array.Size(); i++)
|
||||||
{
|
{
|
||||||
READER_ASSERT(string_array[i].IsString(), (prefix + "Slider '" + name + "': strings[" + std::to_string(i) + "]: must be a string\n").c_str());
|
if (!READER_CHECK(string_array[i].IsString(), (prefix + "Slider '" + name + "': strings[" + std::to_string(i) + "]: must be a string\n").c_str()))
|
||||||
|
{
|
||||||
|
return sliders;
|
||||||
|
}
|
||||||
strings.push_back(std::string(string_array[i].GetString()));
|
strings.push_back(std::string(string_array[i].GetString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int slider_count;
|
int slider_count;
|
||||||
std::vector<bgfx_slider*> sliders;
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case bgfx_slider::slider_type::SLIDER_FLOAT:
|
case bgfx_slider::slider_type::SLIDER_FLOAT:
|
||||||
@ -82,9 +88,9 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
|||||||
int min[3];
|
int min[3];
|
||||||
int defaults[3];
|
int defaults[3];
|
||||||
int max[3];
|
int max[3];
|
||||||
READER_ASSERT(value["min"].IsArray(), (prefix + "Slider '" + name + "': value 'min' must be an array\n").c_str());
|
if (!READER_CHECK(value["min"].IsArray(), (prefix + "Slider '" + name + "': value 'min' must be an array\n").c_str())) return sliders;
|
||||||
READER_ASSERT(value["default"].IsArray(), (prefix + "Slider '" + name + "': value 'default' must be an array\n").c_str());
|
if (!READER_CHECK(value["default"].IsArray(), (prefix + "Slider '" + name + "': value 'default' must be an array\n").c_str())) return sliders;
|
||||||
READER_ASSERT(value["max"].IsArray(), (prefix + "Slider '" + name + "': value 'max' must be an array\n").c_str());
|
if (!READER_CHECK(value["max"].IsArray(), (prefix + "Slider '" + name + "': value 'max' must be an array\n").c_str())) return sliders;
|
||||||
get_values(value, prefix + "Slider '" + name + "': 'min': ", "min", min, slider_count);
|
get_values(value, prefix + "Slider '" + name + "': 'min': ", "min", min, slider_count);
|
||||||
get_values(value, prefix + "Slider '" + name + "': 'default': ", "default", defaults, slider_count);
|
get_values(value, prefix + "Slider '" + name + "': 'default': ", "default", defaults, slider_count);
|
||||||
get_values(value, prefix + "Slider '" + name + "': 'max': ", "max", max, slider_count);
|
get_values(value, prefix + "Slider '" + name + "': 'max': ", "max", max, slider_count);
|
||||||
@ -120,37 +126,40 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
|||||||
return sliders;
|
return sliders;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slider_reader::get_values(const Value& value, std::string prefix, std::string name, int* values, const int count)
|
bool slider_reader::get_values(const Value& value, std::string prefix, std::string name, int* values, const int count)
|
||||||
{
|
{
|
||||||
const char* name_str = name.c_str();
|
const char* name_str = name.c_str();
|
||||||
const Value& value_array = value[name_str];
|
const Value& value_array = value[name_str];
|
||||||
for (UINT32 i = 0; i < value_array.Size() && i < count; i++)
|
for (UINT32 i = 0; i < value_array.Size() && i < count; i++)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value_array[i].IsInt(), (prefix + "Entry " + std::to_string(i) + " must be an integer\n").c_str());
|
if (!READER_CHECK(value_array[i].IsInt(), (prefix + "Entry " + std::to_string(i) + " must be an integer\n").c_str())) return false;
|
||||||
values[i] = value_array[i].GetInt();
|
values[i] = value_array[i].GetInt();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slider_reader::validate_parameters(const Value& value, std::string prefix)
|
bool slider_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str());
|
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str());
|
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("min"), (prefix + "Must have integer or array value 'min'\n").c_str());
|
if (!READER_CHECK(value.HasMember("min"), (prefix + "Must have integer or array value 'min'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["min"].IsInt() || value["min"].IsArray(), (prefix + "Value 'min' must be an integer or an array the size of the corresponding slider type\n").c_str());
|
if (!READER_CHECK(value["min"].IsInt() || value["min"].IsArray(), (prefix + "Value 'min' must be an integer or an array the size of the corresponding slider type\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("default"), (prefix + "Must have integer or array value 'default'\n").c_str());
|
if (!READER_CHECK(value.HasMember("default"), (prefix + "Must have integer or array value 'default'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["default"].IsInt() || value["default"].IsArray(), (prefix + "Value 'default' must be an integer or an array the size of the corresponding slider type\n").c_str());
|
if (!READER_CHECK(value["default"].IsInt() || value["default"].IsArray(), (prefix + "Value 'default' must be an integer or an array the size of the corresponding slider type\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("max"), (prefix + "Must have integer or array value 'max'\n").c_str());
|
if (!READER_CHECK(value.HasMember("max"), (prefix + "Must have integer or array value 'max'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["max"].IsInt() || value["max"].IsArray(), (prefix + "Value 'max' must be an integer or an array the size of the corresponding slider type\n").c_str());
|
if (!READER_CHECK(value["max"].IsInt() || value["max"].IsArray(), (prefix + "Value 'max' must be an integer or an array the size of the corresponding slider type\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("step"), (prefix + "Must have integer value 'step'\n").c_str());
|
if (!READER_CHECK(value.HasMember("step"), (prefix + "Must have integer value 'step'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["step"].IsInt(), (prefix + "Value 'step' must be an integer (how much does this slider increment by internally?)\n").c_str());
|
if (!READER_CHECK(value["step"].IsInt(), (prefix + "Value 'step' must be an integer (how much does this slider increment by internally?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("type"), (prefix + "Must have string value 'type'\n").c_str());
|
if (!READER_CHECK(value.HasMember("type"), (prefix + "Must have string value 'type'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["type"].IsString(), (prefix + "Value 'type' must be a string (what type of slider is this? [int_enum, int, float])\n").c_str());
|
if (!READER_CHECK(value["type"].IsString(), (prefix + "Value 'type' must be a string (what type of slider is this? [int_enum, int, float])\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("screen"), (prefix + "Must have string value 'screen'\n").c_str());
|
if (!READER_CHECK(value.HasMember("screen"), (prefix + "Must have string value 'screen'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["screen"].IsString(), (prefix + "Value 'screen' must be a string (what type of output device does this slider apply to? [none, raster, vector, crt, lcd, non_vector, any])\n").c_str());
|
if (!READER_CHECK(value["screen"].IsString(), (prefix + "Value 'screen' must be a string (what type of output device does this slider apply to? [none, raster, vector, crt, lcd, non_vector, any])\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("scale"), (prefix + "Must have numeric value 'scale'\n").c_str());
|
if (!READER_CHECK(value.HasMember("scale"), (prefix + "Must have numeric value 'scale'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["scale"].IsNumber(), (prefix + "Value 'scale' must be a number (what do we multiply with to get 1.0?)").c_str());
|
if (!READER_CHECK(value["scale"].IsNumber(), (prefix + "Value 'scale' must be a number (what do we multiply with to get 1.0?)").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("format"), (prefix + "Must have string value 'format'\n").c_str());
|
if (!READER_CHECK(value.HasMember("format"), (prefix + "Must have string value 'format'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["format"].IsString(), (prefix + "Value 'scale' must be a string (how would we display it in a printf?)").c_str());
|
if (!READER_CHECK(value["format"].IsString(), (prefix + "Value 'scale' must be a string (how would we display it in a printf?)").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("text"), (prefix + "Must have string value 'text'\n").c_str());
|
if (!READER_CHECK(value.HasMember("text"), (prefix + "Must have string value 'text'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["text"].IsString(), (prefix + "Value 'text' must be a string (how would you explain it?)").c_str());
|
if (!READER_CHECK(value["text"].IsString(), (prefix + "Value 'text' must be a string (how would you explain it?)").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("strings") || value["strings"].IsArray(), (prefix + "Value 'strings' must be an array\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ 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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void get_values(const Value& value, std::string prefix, std::string name, int* values, const int count);
|
static bool get_values(const Value& value, std::string prefix, std::string name, int* values, const int count);
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
|
|
||||||
static const int TYPE_COUNT = 5;
|
static const int TYPE_COUNT = 5;
|
||||||
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
bgfx_entry_uniform* slider_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_slider*>& sliders)
|
bgfx_entry_uniform* slider_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_slider*>& sliders)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = value["slider"].GetString();
|
std::string name = value["slider"].GetString();
|
||||||
std::vector<bgfx_slider*> slider_list;
|
std::vector<bgfx_slider*> slider_list;
|
||||||
@ -35,8 +38,9 @@ bgfx_entry_uniform* slider_uniform_reader::read_from_value(const Value& value, s
|
|||||||
return new bgfx_slider_uniform(uniform, slider_list);
|
return new bgfx_slider_uniform(uniform, slider_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void slider_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
bool slider_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("slider"), (prefix + "Must have string value 'slider' (what slider are we getting the value of?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("slider"), (prefix + "Must have string value 'slider' (what slider are we getting the value of?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["slider"].IsString(), (prefix + "Value 'slider' must be a string\n").c_str());
|
if (!READER_CHECK(value["slider"].IsString(), (prefix + "Value 'slider' must be a string\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_slider*>& sliders);
|
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_slider*>& sliders);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_SLIDER_UNIFORM_READER__
|
#endif // __DRAWBGFX_SLIDER_UNIFORM_READER__
|
||||||
|
@ -36,7 +36,7 @@ protected:
|
|||||||
static uint64_t get_param_from_string(std::string value, const string_to_enum* enums, const int count);
|
static uint64_t get_param_from_string(std::string value, const string_to_enum* enums, const int count);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void READER_ASSERT(bool condition, const char* format, ...)
|
static bool READER_CHECK(bool condition, const char* format, ...)
|
||||||
{
|
{
|
||||||
if (!condition)
|
if (!condition)
|
||||||
{
|
{
|
||||||
@ -44,10 +44,10 @@ protected:
|
|||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
vsnprintf(buf, 2048, format, ap);
|
vsnprintf(buf, 2048, format, ap);
|
||||||
printf("%s\n", buf);
|
osd_printf_error("Error: %s\n", buf);
|
||||||
fflush(stdout);
|
va_end(ap);
|
||||||
fatalerror("%s", buf);
|
|
||||||
}
|
}
|
||||||
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -25,7 +25,10 @@ const suppressor_reader::string_to_enum suppressor_reader::COMBINE_NAMES[suppres
|
|||||||
|
|
||||||
bgfx_suppressor* suppressor_reader::read_from_value(const Value& value, std::string prefix, std::map<std::string, bgfx_slider*>& sliders)
|
bgfx_suppressor* suppressor_reader::read_from_value(const Value& value, std::string prefix, std::map<std::string, bgfx_slider*>& sliders)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = value["name"].GetString();
|
std::string name = value["name"].GetString();
|
||||||
uint32_t condition = uint32_t(get_enum_from_value(value, "condition", bgfx_suppressor::condition_type::CONDITION_EQUAL, CONDITION_NAMES, CONDITION_COUNT));
|
uint32_t condition = uint32_t(get_enum_from_value(value, "condition", bgfx_suppressor::condition_type::CONDITION_EQUAL, CONDITION_NAMES, CONDITION_COUNT));
|
||||||
@ -57,6 +60,7 @@ bgfx_suppressor* suppressor_reader::read_from_value(const Value& value, std::str
|
|||||||
if (slider_count > 1)
|
if (slider_count > 1)
|
||||||
{
|
{
|
||||||
get_values(value, prefix, "value", values, slider_count);
|
get_values(value, prefix, "value", values, slider_count);
|
||||||
|
if (!READER_CHECK(slider_count == value["value"].GetArray().Size(), (prefix + "Expected " + std::to_string(slider_count) + " values, got " + std::to_string(value["value"].GetArray().Size()) + "\n").c_str())) return nullptr;
|
||||||
for (int index = 1; index < slider_count; index++)
|
for (int index = 1; index < slider_count; index++)
|
||||||
{
|
{
|
||||||
check_sliders.push_back(sliders[name + std::to_string(index)]);
|
check_sliders.push_back(sliders[name + std::to_string(index)]);
|
||||||
@ -70,21 +74,23 @@ bgfx_suppressor* suppressor_reader::read_from_value(const Value& value, std::str
|
|||||||
return new bgfx_suppressor(check_sliders, condition, mode, values);
|
return new bgfx_suppressor(check_sliders, condition, mode, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
void suppressor_reader::validate_parameters(const Value& value, std::string prefix)
|
bool suppressor_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str());
|
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str());
|
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
|
||||||
READER_ASSERT(value.HasMember("value"), (prefix + "Must have numeric or array value 'value'\n").c_str());
|
if (!READER_CHECK(value.HasMember("value"), (prefix + "Must have numeric or array value 'value'\n").c_str())) return false;
|
||||||
READER_ASSERT(value["value"].IsNumber() || value["value"].IsArray(), (prefix + "Value 'value' must be a number or array the size of the corresponding slider type\n").c_str());
|
if (!READER_CHECK(value["value"].IsNumber() || value["value"].IsArray(), (prefix + "Value 'value' must be a number or array the size of the corresponding slider type\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void suppressor_reader::get_values(const Value& value, std::string prefix, std::string name, int* values, const int count)
|
bool suppressor_reader::get_values(const Value& value, std::string prefix, std::string name, int* values, const int count)
|
||||||
{
|
{
|
||||||
const char* name_str = name.c_str();
|
const char* name_str = name.c_str();
|
||||||
const Value& value_array = value[name_str];
|
const Value& value_array = value[name_str];
|
||||||
for (UINT32 i = 0; i < value_array.Size() && i < count; i++)
|
for (UINT32 i = 0; i < value_array.Size() && i < count; i++)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value_array[i].IsInt(), (prefix + "value[" + std::to_string(i) + "] must be an integer\n").c_str());
|
if (!READER_CHECK(value_array[i].IsInt(), (prefix + "value[" + std::to_string(i) + "] must be an integer\n").c_str())) return false;
|
||||||
values[i] = value_array[i].GetInt();
|
values[i] = value_array[i].GetInt();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,8 @@ public:
|
|||||||
static bgfx_suppressor* read_from_value(const Value& value, std::string prefix, std::map<std::string, bgfx_slider*>& sliders);
|
static bgfx_suppressor* read_from_value(const Value& value, std::string prefix, std::map<std::string, bgfx_slider*>& sliders);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void get_values(const Value& value, std::string prefix, std::string name, int* values, const int count);
|
static bool get_values(const Value& value, std::string prefix, std::string name, int* values, const int count);
|
||||||
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
|
||||||
|
|
||||||
static const int CONDITION_COUNT = 2;
|
static const int CONDITION_COUNT = 2;
|
||||||
static const string_to_enum CONDITION_NAMES[CONDITION_COUNT];
|
static const string_to_enum CONDITION_NAMES[CONDITION_COUNT];
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter, bool init)
|
bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter, bool init, bool output)
|
||||||
: m_name(name)
|
: m_name(name)
|
||||||
, m_format(format)
|
, m_format(format)
|
||||||
, m_targets(nullptr)
|
, m_targets(nullptr)
|
||||||
@ -20,6 +20,7 @@ bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uin
|
|||||||
, m_double_buffer(double_buffer)
|
, m_double_buffer(double_buffer)
|
||||||
, m_style(style)
|
, m_style(style)
|
||||||
, m_filter(filter)
|
, m_filter(filter)
|
||||||
|
, m_output(output)
|
||||||
, m_current_page(0)
|
, m_current_page(0)
|
||||||
, m_initialized(false)
|
, m_initialized(false)
|
||||||
, m_page_count(double_buffer ? 2 : 1)
|
, m_page_count(double_buffer ? 2 : 1)
|
||||||
|
@ -27,7 +27,7 @@ enum
|
|||||||
class bgfx_target : public bgfx_texture_handle_provider
|
class bgfx_target : public bgfx_texture_handle_provider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter, bool init = true);
|
bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter, bool init = true, bool output = false);
|
||||||
bgfx_target(void *handle, uint16_t width, uint16_t height);
|
bgfx_target(void *handle, uint16_t width, uint16_t height);
|
||||||
virtual ~bgfx_target();
|
virtual ~bgfx_target();
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ public:
|
|||||||
bool filter() const { return m_filter; }
|
bool filter() const { return m_filter; }
|
||||||
uint32_t prescale_x() const { return m_prescale_x; }
|
uint32_t prescale_x() const { return m_prescale_x; }
|
||||||
uint32_t prescale_y() const { return m_prescale_y; }
|
uint32_t prescale_y() const { return m_prescale_y; }
|
||||||
|
bool output() const { return m_output; }
|
||||||
|
|
||||||
// bgfx_texture_handle_provider
|
// bgfx_texture_handle_provider
|
||||||
virtual uint16_t width() const override { return m_width; }
|
virtual uint16_t width() const override { return m_width; }
|
||||||
@ -65,6 +66,7 @@ private:
|
|||||||
bool m_double_buffer;
|
bool m_double_buffer;
|
||||||
uint32_t m_style;
|
uint32_t m_style;
|
||||||
bool m_filter;
|
bool m_filter;
|
||||||
|
bool m_output;
|
||||||
|
|
||||||
uint32_t m_current_page;
|
uint32_t m_current_page;
|
||||||
|
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "modules/lib/osdobj_common.h"
|
||||||
|
|
||||||
#include "targetmanager.h"
|
#include "targetmanager.h"
|
||||||
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
target_manager::~target_manager()
|
target_manager::~target_manager()
|
||||||
@ -25,9 +28,9 @@ target_manager::~target_manager()
|
|||||||
m_targets.clear();
|
m_targets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter)
|
bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter, bool output)
|
||||||
{
|
{
|
||||||
bgfx_target* target = new bgfx_target(name, format, width, height, prescale_x, prescale_y, style, double_buffer, filter, width > 0 && height > 0);
|
bgfx_target* target = new bgfx_target(name, format, width, height, prescale_x, prescale_y, style, double_buffer, filter, width > 0 && height > 0, output);
|
||||||
m_targets[name] = target;
|
m_targets[name] = target;
|
||||||
|
|
||||||
m_textures.add_provider(name, target);
|
m_textures.add_provider(name, target);
|
||||||
@ -78,8 +81,36 @@ void target_manager::update_guest_targets(uint16_t width, uint16_t height)
|
|||||||
const uint32_t prescale_y = target->prescale_y();
|
const uint32_t prescale_y = target->prescale_y();
|
||||||
delete target;
|
delete target;
|
||||||
|
|
||||||
m_targets[name] = new bgfx_target(name, format, width, height, prescale_x, prescale_y, TARGET_STYLE_GUEST, double_buffered, filter);
|
m_targets[name] = new bgfx_target(name, format, m_guest_width, m_guest_height, prescale_x, prescale_y, TARGET_STYLE_GUEST, double_buffered, filter);
|
||||||
m_textures.add_provider(name, m_targets[name]);
|
m_textures.add_provider(name, m_targets[name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void target_manager::update_window_count(uint32_t count)
|
||||||
|
{
|
||||||
|
if (count != m_window_count)
|
||||||
|
{
|
||||||
|
m_window_count = count;
|
||||||
|
rebuild_outputs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void target_manager::rebuild_outputs()
|
||||||
|
{
|
||||||
|
for (uint32_t i = 0; i < m_window_count; i++)
|
||||||
|
{
|
||||||
|
rebuild_target("output" + std::to_string(i));
|
||||||
|
rebuild_target("previous" + std::to_string(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void target_manager::rebuild_target(std::string name)
|
||||||
|
{
|
||||||
|
bgfx_target* target = m_targets[name];
|
||||||
|
if (target != nullptr) {
|
||||||
|
delete target;
|
||||||
|
}
|
||||||
|
m_targets[name] = new bgfx_target(name, bgfx::TextureFormat::RGBA8, m_guest_width, m_guest_height, m_options.bgfx_prescale_x(), m_options.bgfx_prescale_y(), TARGET_STYLE_GUEST, true, true);
|
||||||
|
m_textures.add_provider(name, m_targets[name]);
|
||||||
|
}
|
@ -22,16 +22,18 @@
|
|||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
|
|
||||||
class bgfx_target;
|
class bgfx_target;
|
||||||
|
class osd_options;
|
||||||
|
|
||||||
class target_manager {
|
class target_manager {
|
||||||
public:
|
public:
|
||||||
target_manager(texture_manager& textures) : m_textures(textures), m_guest_width(0), m_guest_height(0) { }
|
target_manager(osd_options& options, texture_manager& textures) : m_textures(textures), m_options(options), m_guest_width(0), m_guest_height(0), m_window_count(0) { }
|
||||||
~target_manager();
|
~target_manager();
|
||||||
|
|
||||||
bgfx_target* create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter);
|
bgfx_target* create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, uint32_t prescale_x, uint32_t prescale_y, uint32_t style, bool double_buffer, bool filter, bool output);
|
||||||
bgfx_target* create_backbuffer(void *handle, uint32_t width, uint32_t height);
|
bgfx_target* create_backbuffer(void *handle, uint32_t width, uint32_t height);
|
||||||
|
|
||||||
void update_guest_targets(uint16_t width, uint16_t height);
|
void update_guest_targets(uint16_t width, uint16_t height);
|
||||||
|
void update_window_count(uint32_t count);
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
bgfx_target* target(std::string name);
|
bgfx_target* target(std::string name);
|
||||||
@ -39,11 +41,16 @@ public:
|
|||||||
uint16_t guest_height() const { return m_guest_height; }
|
uint16_t guest_height() const { return m_guest_height; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void rebuild_outputs();
|
||||||
|
void rebuild_target(std::string name);
|
||||||
|
|
||||||
std::map<std::string, bgfx_target*> m_targets;
|
std::map<std::string, bgfx_target*> m_targets;
|
||||||
texture_manager& m_textures;
|
texture_manager& m_textures;
|
||||||
|
osd_options& m_options;
|
||||||
|
|
||||||
uint16_t m_guest_width;
|
uint16_t m_guest_width;
|
||||||
uint16_t m_guest_height;
|
uint16_t m_guest_height;
|
||||||
|
uint32_t m_window_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_TARGET_MANAGER__
|
#endif // __DRAWBGFX_TARGET_MANAGER__
|
||||||
|
87
src/osd/modules/render/bgfx/targetreader.cpp
Normal file
87
src/osd/modules/render/bgfx/targetreader.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:Ryan Holtz
|
||||||
|
//============================================================
|
||||||
|
//
|
||||||
|
// targetreader.cpp - BGFX target JSON reader
|
||||||
|
//
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "emu.h"
|
||||||
|
#include <modules/lib/osdobj_common.h>
|
||||||
|
|
||||||
|
#include "targetreader.h"
|
||||||
|
#include "targetmanager.h"
|
||||||
|
#include "target.h"
|
||||||
|
|
||||||
|
const target_reader::string_to_enum target_reader::STYLE_NAMES[target_reader::STYLE_COUNT] = {
|
||||||
|
{ "guest", TARGET_STYLE_GUEST },
|
||||||
|
{ "native", TARGET_STYLE_NATIVE },
|
||||||
|
{ "custom", TARGET_STYLE_CUSTOM }
|
||||||
|
};
|
||||||
|
|
||||||
|
bool target_reader::read_from_value(const Value& value, std::string prefix, target_manager& targets, osd_options& options, uint32_t screen_width, uint32_t screen_height)
|
||||||
|
{
|
||||||
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string target_name = value["name"].GetString();
|
||||||
|
uint32_t mode = uint32_t(get_enum_from_value(value, "mode", TARGET_STYLE_NATIVE, STYLE_NAMES, STYLE_COUNT));
|
||||||
|
bool bilinear = get_bool(value, "bilinear", true);
|
||||||
|
bool double_buffer = get_bool(value, "doublebuffer", true);
|
||||||
|
bool prescale = get_bool(value, "prescale", false);
|
||||||
|
bool output = get_bool(value, "output", false);
|
||||||
|
|
||||||
|
uint16_t width = 0;
|
||||||
|
uint16_t height = 0;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case TARGET_STYLE_GUEST:
|
||||||
|
width = targets.guest_width();
|
||||||
|
height = targets.guest_height();
|
||||||
|
break;
|
||||||
|
case TARGET_STYLE_NATIVE:
|
||||||
|
width = screen_width;
|
||||||
|
height = screen_height;
|
||||||
|
break;
|
||||||
|
case TARGET_STYLE_CUSTOM:
|
||||||
|
if (!READER_CHECK(value.HasMember("width"), (prefix + "Target '" + target_name + "': Must have numeric value 'width'\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["width"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'width' must be a number\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value.HasMember("height"), (prefix + "Target '" + target_name + "': Must have numeric value 'height'\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["height"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'height' must be a number\n").c_str())) return false;
|
||||||
|
width = uint32_t(value["width"].GetDouble());
|
||||||
|
height = uint32_t(value["height"].GetDouble());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t prescale_x = 1;
|
||||||
|
uint32_t prescale_y = 1;
|
||||||
|
if (prescale)
|
||||||
|
{
|
||||||
|
prescale_x = options.bgfx_prescale_x();
|
||||||
|
prescale_y = options.bgfx_prescale_y();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!output)
|
||||||
|
{
|
||||||
|
targets.create_target(target_name, bgfx::TextureFormat::RGBA8, width, height, prescale_x, prescale_y, mode, double_buffer, bilinear, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool target_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
|
{
|
||||||
|
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value.HasMember("mode"), (prefix + "Must have string enum 'mode'\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["mode"].IsString(), (prefix + "Value 'mode' must be a string (what screens does this apply to?)\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("bilinear") || value["bilinear"].IsBool(), (prefix + "Value 'bilinear' must be a boolean\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("doublebuffer") || value["doublebuffer"].IsBool(), (prefix + "Value 'doublebuffer' must be a boolean\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("prescale") || value["prescale"].IsBool(), (prefix + "Value 'prescale' must be a boolean\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(!value.HasMember("output") || value["output"].IsBool(), (prefix + "Value 'output' must be a boolean\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
|
}
|
33
src/osd/modules/render/bgfx/targetreader.h
Normal file
33
src/osd/modules/render/bgfx/targetreader.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:Ryan Holtz
|
||||||
|
//============================================================
|
||||||
|
//
|
||||||
|
// targetreader.h - BGFX target JSON reader
|
||||||
|
//
|
||||||
|
//============================================================
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __DRAWBGFX_TARGET_READER__
|
||||||
|
#define __DRAWBGFX_TARGET_READER__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "statereader.h"
|
||||||
|
|
||||||
|
class target_manager;
|
||||||
|
class osd_options;
|
||||||
|
|
||||||
|
class target_reader : public state_reader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool read_from_value(const Value& value, std::string prefix, target_manager& targets, osd_options& options, uint32_t screen_width, uint32_t screen_height);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
|
|
||||||
|
static const int STYLE_COUNT = 3;
|
||||||
|
static const string_to_enum STYLE_NAMES[STYLE_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __DRAWBGFX_TARGET_READER__
|
@ -7,28 +7,27 @@
|
|||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
#include "uniformreader.h"
|
#include "uniformreader.h"
|
||||||
|
|
||||||
#include "uniform.h"
|
#include "uniform.h"
|
||||||
|
|
||||||
const uniform_reader::string_to_enum uniform_reader::TYPE_NAMES[uniform_reader::TYPE_COUNT] = {
|
const uniform_reader::string_to_enum uniform_reader::TYPE_NAMES[uniform_reader::TYPE_COUNT] = {
|
||||||
{ "int", bgfx::UniformType::Int1 },
|
{ "int", bgfx::UniformType::Int1 },
|
||||||
{ "vec4", bgfx::UniformType::Vec4 },
|
{ "vec4", bgfx::UniformType::Vec4 },
|
||||||
{ "mat3", bgfx::UniformType::Mat3 },
|
{ "mat3", bgfx::UniformType::Mat3 },
|
||||||
{ "mat4", bgfx::UniformType::Mat4 },
|
{ "mat4", bgfx::UniformType::Mat4 }
|
||||||
{ "camera", bgfx::UniformType::Mat4 }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bgfx_uniform* uniform_reader::read_from_value(const Value& value)
|
bgfx_uniform* uniform_reader::read_from_value(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
assert(value.HasMember("name"));
|
if (!validate_parameters(value, prefix))
|
||||||
assert(value["name"].IsString());
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
const char* name = value["name"].GetString();
|
const char* name = value["name"].GetString();
|
||||||
|
|
||||||
assert(value.HasMember("type"));
|
|
||||||
bgfx::UniformType::Enum type = bgfx::UniformType::Enum(get_enum_from_value(value, "type", bgfx::UniformType::Vec4, TYPE_NAMES, TYPE_COUNT));
|
bgfx::UniformType::Enum type = bgfx::UniformType::Enum(get_enum_from_value(value, "type", bgfx::UniformType::Vec4, TYPE_NAMES, TYPE_COUNT));
|
||||||
const size_t type_size = bgfx_uniform::get_size_for_type(type);
|
const size_t type_size = bgfx_uniform::get_size_for_type(type);
|
||||||
|
|
||||||
assert(value.HasMember("values"));
|
|
||||||
assert(value["values"].IsArray());
|
|
||||||
const Value& value_array = value["values"];
|
const Value& value_array = value["values"];
|
||||||
const size_t array_size = value_array.Size() * sizeof(float);
|
const size_t array_size = value_array.Size() * sizeof(float);
|
||||||
|
|
||||||
@ -52,3 +51,13 @@ bgfx_uniform* uniform_reader::read_from_value(const Value& value)
|
|||||||
|
|
||||||
return uniform;
|
return uniform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
|
{
|
||||||
|
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'name' (what is this uniform called in the shader code?)\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value.HasMember("type"), (prefix + "Must have string value 'type' [int, vec4, mat3, mat4]\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value.HasMember("values"), (prefix + "Must have array value 'values' (what are the uniform's default values?)\n").c_str())) return false;
|
||||||
|
if (!READER_CHECK(value["values"].IsArray(), (prefix + "Value 'values' must be an array\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -17,24 +17,15 @@
|
|||||||
|
|
||||||
class bgfx_uniform;
|
class bgfx_uniform;
|
||||||
|
|
||||||
enum uniform_type
|
|
||||||
{
|
|
||||||
TYPE_INT1 = bgfx::UniformType::Int1,
|
|
||||||
TYPE_VEC4 = bgfx::UniformType::Vec4,
|
|
||||||
TYPE_MAT3 = bgfx::UniformType::Mat3,
|
|
||||||
TYPE_MAT4 = bgfx::UniformType::Mat4,
|
|
||||||
TYPE_CAMERA, // Alias for the current ortho camera, used to auto-bind on material load
|
|
||||||
|
|
||||||
TYPE_COUNT = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
class uniform_reader : public state_reader
|
class uniform_reader : public state_reader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bgfx_uniform* read_from_value(const Value& value);
|
static bgfx_uniform* read_from_value(const Value& value, std::string prefix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int TYPE_COUNT = uniform_type::TYPE_COUNT;
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
|
|
||||||
|
static const int TYPE_COUNT = 4;
|
||||||
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
|
|
||||||
bgfx_entry_uniform* value_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform)
|
bgfx_entry_uniform* value_uniform_reader::read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform)
|
||||||
{
|
{
|
||||||
validate_parameters(value, prefix);
|
if (!validate_parameters(value, prefix))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
float values[4];
|
float values[4];
|
||||||
int count = 1;
|
int count = 1;
|
||||||
@ -33,8 +36,9 @@ bgfx_entry_uniform* value_uniform_reader::read_from_value(const Value& value, st
|
|||||||
return new bgfx_value_uniform(uniform, values, count);
|
return new bgfx_value_uniform(uniform, values, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void value_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
bool value_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||||
{
|
{
|
||||||
READER_ASSERT(value.HasMember("value"), (prefix + "Must have string value 'value' (what value is being assigned?)\n").c_str());
|
if (!READER_CHECK(value.HasMember("value"), (prefix + "Must have string value 'value' (what value is being assigned?)\n").c_str())) return false;
|
||||||
READER_ASSERT(value["value"].IsArray() || value["value"].IsNumber(), (prefix + "Value 'value' must be numeric or an array\n").c_str());
|
if (!READER_CHECK(value["value"].IsArray() || value["value"].IsNumber(), (prefix + "Value 'value' must be numeric or an array\n").c_str())) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform);
|
static bgfx_entry_uniform* read_from_value(const Value& value, std::string prefix, bgfx_uniform* uniform);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void validate_parameters(const Value& value, std::string prefix);
|
static bool validate_parameters(const Value& value, std::string prefix);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __DRAWBGFX_VALUE_UNIFORM_READER__
|
#endif // __DRAWBGFX_VALUE_UNIFORM_READER__
|
||||||
|
@ -65,11 +65,6 @@ const char* renderer_bgfx::WINDOW_PREFIX = "Window 0, ";
|
|||||||
|
|
||||||
#define GIBBERISH (0)
|
#define GIBBERISH (0)
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// INLINES
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// TYPES
|
// TYPES
|
||||||
//============================================================
|
//============================================================
|
||||||
@ -168,7 +163,7 @@ int renderer_bgfx::create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_textures = new texture_manager();
|
m_textures = new texture_manager();
|
||||||
m_targets = new target_manager(*m_textures);
|
m_targets = new target_manager(options, *m_textures);
|
||||||
|
|
||||||
m_shaders = new shader_manager(options);
|
m_shaders = new shader_manager(options);
|
||||||
m_effects = new effect_manager(options, *m_shaders);
|
m_effects = new effect_manager(options, *m_shaders);
|
||||||
@ -353,14 +348,22 @@ void renderer_bgfx::process_screen_quad(int view, render_primitive* prim)
|
|||||||
bgfx_texture *texture = new bgfx_texture("screen", bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem);
|
bgfx_texture *texture = new bgfx_texture("screen", bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem);
|
||||||
m_textures->add_provider("screen", texture);
|
m_textures->add_provider("screen", texture);
|
||||||
|
|
||||||
|
int screens = 0;
|
||||||
|
screen_device_iterator iter(window().machine().root_device());
|
||||||
|
for (const screen_device *screen = iter.first(); screen != nullptr; screen = iter.next())
|
||||||
|
{
|
||||||
|
screens++;
|
||||||
|
}
|
||||||
m_targets->update_guest_targets(tex_width, tex_height);
|
m_targets->update_guest_targets(tex_width, tex_height);
|
||||||
m_screen_chain->process(prim, view, *m_textures, window(), get_blend_state(PRIMFLAG_GET_BLENDMODE(prim->flags)));
|
m_targets->update_window_count(screens);
|
||||||
|
|
||||||
|
m_screen_chain->process(prim, view, view / m_screen_chain->applicable_passes(), *m_textures, window(), get_blend_state(PRIMFLAG_GET_BLENDMODE(prim->flags)));
|
||||||
|
|
||||||
m_textures->add_provider("screen", nullptr);
|
m_textures->add_provider("screen", nullptr);
|
||||||
delete texture;
|
delete texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderer_bgfx::render_post_screen_quad(int view, render_primitive* prim, bgfx::TransientVertexBuffer* buffer)
|
void renderer_bgfx::render_post_screen_quad(int view, render_primitive* prim, bgfx::TransientVertexBuffer* buffer, int32_t screen)
|
||||||
{
|
{
|
||||||
ScreenVertex* vertex = reinterpret_cast<ScreenVertex*>(buffer->data);
|
ScreenVertex* vertex = reinterpret_cast<ScreenVertex*>(buffer->data);
|
||||||
|
|
||||||
@ -369,13 +372,13 @@ void renderer_bgfx::render_post_screen_quad(int view, render_primitive* prim, bg
|
|||||||
float u[4] = { prim->texcoords.tl.u, prim->texcoords.tr.u, prim->texcoords.bl.u, prim->texcoords.br.u };
|
float u[4] = { prim->texcoords.tl.u, prim->texcoords.tr.u, prim->texcoords.bl.u, prim->texcoords.br.u };
|
||||||
float v[4] = { prim->texcoords.tl.v, prim->texcoords.tr.v, prim->texcoords.bl.v, prim->texcoords.br.v };
|
float v[4] = { prim->texcoords.tl.v, prim->texcoords.tr.v, prim->texcoords.bl.v, prim->texcoords.br.v };
|
||||||
|
|
||||||
if (PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_SWAP_XY)
|
if (false)//PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_SWAP_XY)
|
||||||
{
|
{
|
||||||
std::swap(u[1], u[2]);
|
std::swap(u[1], u[2]);
|
||||||
std::swap(v[1], v[2]);
|
std::swap(v[1], v[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_FLIP_X)
|
if (false)//PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_FLIP_X)
|
||||||
{
|
{
|
||||||
std::swap(u[0], u[1]);
|
std::swap(u[0], u[1]);
|
||||||
std::swap(v[0], v[1]);
|
std::swap(v[0], v[1]);
|
||||||
@ -383,7 +386,7 @@ void renderer_bgfx::render_post_screen_quad(int view, render_primitive* prim, bg
|
|||||||
std::swap(v[2], v[3]);
|
std::swap(v[2], v[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_FLIP_Y)
|
if (false)//PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_FLIP_Y)
|
||||||
{
|
{
|
||||||
std::swap(u[0], u[2]);
|
std::swap(u[0], u[2]);
|
||||||
std::swap(v[0], v[2]);
|
std::swap(v[0], v[2]);
|
||||||
@ -435,7 +438,7 @@ void renderer_bgfx::render_post_screen_quad(int view, render_primitive* prim, bg
|
|||||||
|
|
||||||
UINT32 blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
|
UINT32 blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
|
||||||
bgfx::setVertexBuffer(buffer);
|
bgfx::setVertexBuffer(buffer);
|
||||||
bgfx::setTexture(0, m_screen_effect[blend]->uniform("s_tex")->handle(), m_targets->target(m_screen_chain->output())->texture());
|
bgfx::setTexture(0, m_screen_effect[blend]->uniform("s_tex")->handle(), m_targets->target("output" + std::to_string(screen))->texture());
|
||||||
m_screen_effect[blend]->submit(view);
|
m_screen_effect[blend]->submit(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,47 +734,52 @@ const bgfx::Memory* renderer_bgfx::mame_texture_data_to_bgfx_texture_data(UINT32
|
|||||||
|
|
||||||
int renderer_bgfx::handle_screen_chains()
|
int renderer_bgfx::handle_screen_chains()
|
||||||
{
|
{
|
||||||
window().m_primlist->acquire_lock();
|
if (!m_screen_chain)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int view = 0;
|
window().m_primlist->acquire_lock();
|
||||||
|
|
||||||
// process
|
// process
|
||||||
render_primitive *prim = window().m_primlist->first();
|
render_primitive *prim = window().m_primlist->first();
|
||||||
|
|
||||||
|
int seen = 0;
|
||||||
while (prim != nullptr)
|
while (prim != nullptr)
|
||||||
{
|
{
|
||||||
if (PRIMFLAG_GET_SCREENTEX(prim->flags))
|
if (PRIMFLAG_GET_SCREENTEX(prim->flags))
|
||||||
{
|
{
|
||||||
process_screen_quad(view, prim);
|
process_screen_quad(m_screen_chain->applicable_passes() * seen, prim);
|
||||||
const int applicable_passes = m_screen_chain->applicable_passes();
|
seen++;
|
||||||
bgfx::setViewFrameBuffer(applicable_passes, BGFX_INVALID_HANDLE);
|
|
||||||
window().m_primlist->release_lock();
|
|
||||||
return applicable_passes * (window().m_index + 1);
|
|
||||||
}
|
}
|
||||||
prim = prim->next();
|
prim = prim->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
window().m_primlist->release_lock();
|
window().m_primlist->release_lock();
|
||||||
|
|
||||||
return 0;
|
uint32_t total_passes = seen * m_screen_chain->applicable_passes();
|
||||||
|
bgfx::setViewFrameBuffer(total_passes, BGFX_INVALID_HANDLE);
|
||||||
|
|
||||||
|
return total_passes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int renderer_bgfx::draw(int update)
|
int renderer_bgfx::draw(int update)
|
||||||
{
|
{
|
||||||
int post_view_index = handle_screen_chains();
|
|
||||||
int window_index = window().m_index;
|
int window_index = window().m_index;
|
||||||
|
int post_view_index = handle_screen_chains();
|
||||||
int view_index = window_index;
|
int view_index = window_index;
|
||||||
int first_view_index = 0;
|
int first_view_index = 0;
|
||||||
if (post_view_index > 0)
|
if (m_screen_chain && post_view_index > 0)
|
||||||
{
|
{
|
||||||
view_index = post_view_index;
|
view_index += post_view_index;
|
||||||
first_view_index = m_screen_chain->applicable_passes();
|
first_view_index = post_view_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set view 0 default viewport.
|
// Set view 0 default viewport.
|
||||||
osd_dim wdim = window().get_size();
|
osd_dim wdim = window().get_size();
|
||||||
m_width[window_index] = wdim.width();
|
m_width[window_index] = wdim.width();
|
||||||
m_height[window_index] = wdim.height();
|
m_height[window_index] = wdim.height();
|
||||||
if (view_index == first_view_index)
|
if (window_index == 0)
|
||||||
{
|
{
|
||||||
if ((m_dimensions != osd_dim(m_width[window_index], m_height[window_index])))
|
if ((m_dimensions != osd_dim(m_width[window_index], m_height[window_index])))
|
||||||
{
|
{
|
||||||
@ -829,6 +837,7 @@ int renderer_bgfx::draw(int update)
|
|||||||
bool atlas_valid = update_atlas();
|
bool atlas_valid = update_atlas();
|
||||||
|
|
||||||
render_primitive *prim = window().m_primlist->first();
|
render_primitive *prim = window().m_primlist->first();
|
||||||
|
int32_t screen = 0;
|
||||||
while (prim != nullptr)
|
while (prim != nullptr)
|
||||||
{
|
{
|
||||||
UINT32 blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
|
UINT32 blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
|
||||||
@ -836,9 +845,14 @@ int renderer_bgfx::draw(int update)
|
|||||||
bgfx::TransientVertexBuffer buffer;
|
bgfx::TransientVertexBuffer buffer;
|
||||||
allocate_buffer(prim, blend, &buffer);
|
allocate_buffer(prim, blend, &buffer);
|
||||||
|
|
||||||
buffer_status status = buffer_primitives(view_index, atlas_valid, &prim, &buffer);
|
buffer_status status = buffer_primitives(view_index, atlas_valid, &prim, &buffer, screen);
|
||||||
|
|
||||||
if (status != BUFFER_EMPTY)
|
if (status == BUFFER_SCREEN)
|
||||||
|
{
|
||||||
|
screen++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != BUFFER_EMPTY && status != BUFFER_SCREEN)
|
||||||
{
|
{
|
||||||
bgfx::setVertexBuffer(&buffer);
|
bgfx::setVertexBuffer(&buffer);
|
||||||
bgfx::setTexture(0, m_gui_effect[blend]->uniform("s_tex")->handle(), m_texture_cache->texture());
|
bgfx::setTexture(0, m_gui_effect[blend]->uniform("s_tex")->handle(), m_texture_cache->texture());
|
||||||
@ -867,7 +881,7 @@ int renderer_bgfx::draw(int update)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer_bgfx::buffer_status renderer_bgfx::buffer_primitives(int view, bool atlas_valid, render_primitive** prim, bgfx::TransientVertexBuffer* buffer)
|
renderer_bgfx::buffer_status renderer_bgfx::buffer_primitives(int view, bool atlas_valid, render_primitive** prim, bgfx::TransientVertexBuffer* buffer, int32_t screen)
|
||||||
{
|
{
|
||||||
int vertices = 0;
|
int vertices = 0;
|
||||||
|
|
||||||
@ -902,15 +916,16 @@ renderer_bgfx::buffer_status renderer_bgfx::buffer_primitives(int view, bool atl
|
|||||||
return BUFFER_PRE_FLUSH;
|
return BUFFER_PRE_FLUSH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRIMFLAG_GET_SCREENTEX((*prim)->flags))
|
if (PRIMFLAG_GET_SCREENTEX((*prim)->flags) && m_screen_chain != nullptr)
|
||||||
{
|
{
|
||||||
render_post_screen_quad(view, *prim, buffer);
|
render_post_screen_quad(view, *prim, buffer, screen);
|
||||||
|
return BUFFER_SCREEN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
render_textured_quad(view, *prim, buffer);
|
render_textured_quad(view, *prim, buffer);
|
||||||
}
|
|
||||||
return BUFFER_EMPTY;
|
return BUFFER_EMPTY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1121,6 +1136,11 @@ void renderer_bgfx::allocate_buffer(render_primitive *prim, UINT32 blend, bgfx::
|
|||||||
|
|
||||||
slider_state* renderer_bgfx::get_slider_list()
|
slider_state* renderer_bgfx::get_slider_list()
|
||||||
{
|
{
|
||||||
|
if (!m_screen_chain)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
slider_state *listhead = nullptr;
|
slider_state *listhead = nullptr;
|
||||||
slider_state **tailptr = &listhead;
|
slider_state **tailptr = &listhead;
|
||||||
std::vector<bgfx_slider*> sliders = m_screen_chain->sliders();
|
std::vector<bgfx_slider*> sliders = m_screen_chain->sliders();
|
||||||
|
@ -67,14 +67,15 @@ private:
|
|||||||
{
|
{
|
||||||
BUFFER_PRE_FLUSH,
|
BUFFER_PRE_FLUSH,
|
||||||
BUFFER_FLUSH,
|
BUFFER_FLUSH,
|
||||||
|
BUFFER_SCREEN,
|
||||||
BUFFER_EMPTY,
|
BUFFER_EMPTY,
|
||||||
BUFFER_DONE
|
BUFFER_DONE
|
||||||
};
|
};
|
||||||
buffer_status buffer_primitives(int view, bool atlas_valid, render_primitive** prim, bgfx::TransientVertexBuffer* buffer);
|
buffer_status buffer_primitives(int view, bool atlas_valid, render_primitive** prim, bgfx::TransientVertexBuffer* buffer, int32_t screen);
|
||||||
|
|
||||||
void process_screen_quad(int view, render_primitive* prim);
|
void process_screen_quad(int view, render_primitive* prim);
|
||||||
void render_textured_quad(int view, render_primitive* prim, bgfx::TransientVertexBuffer* buffer);
|
void render_textured_quad(int view, render_primitive* prim, bgfx::TransientVertexBuffer* buffer);
|
||||||
void render_post_screen_quad(int view, render_primitive* prim, bgfx::TransientVertexBuffer* buffer);
|
void render_post_screen_quad(int view, render_primitive* prim, bgfx::TransientVertexBuffer* buffer, int32_t screen);
|
||||||
|
|
||||||
void put_packed_quad(render_primitive *prim, UINT32 hash, ScreenVertex* vertex);
|
void put_packed_quad(render_primitive *prim, UINT32 hash, ScreenVertex* vertex);
|
||||||
void put_polygon(const float* coords, UINT32 num_coords, float r, UINT32 rgba, ScreenVertex* vertex);
|
void put_polygon(const float* coords, UINT32 num_coords, float r, UINT32 rgba, ScreenVertex* vertex);
|
||||||
|
Loading…
Reference in New Issue
Block a user