mirror of
https://github.com/holub/mame
synced 2025-04-17 22:13:04 +03:00
render/bgfx: Got rid of a lot of unnecessary object copying during setup.
This commit is contained in:
parent
5671484fc8
commit
eaa43879cd
@ -82,7 +82,7 @@ uniform float2 Defocus = float2(0.0f, 0.0f);
|
||||
// now this pass is applied only once with offsets of 0.25, 0.55, 1.0, 1.6 to achieve the same appearance as before till a maximum defocus of 2.0
|
||||
static const float2 CoordOffset8[8] =
|
||||
{
|
||||
// 0.075x<EFBFBD> + 0.225x + 0.25
|
||||
// 0.075x² + 0.225x + 0.25
|
||||
float2(-1.60f, 0.25f),
|
||||
float2(-1.00f, -0.55f),
|
||||
float2(-0.55f, 1.00f),
|
||||
|
@ -27,15 +27,24 @@
|
||||
#include "clear.h"
|
||||
#include "modules/osdwindow.h"
|
||||
|
||||
bgfx_chain::bgfx_chain(std::string name, std::string author, bool transform, target_manager& targets, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries, std::vector<bgfx_target*> target_list, std::uint32_t screen_index)
|
||||
: m_name(name)
|
||||
, m_author(author)
|
||||
bgfx_chain::bgfx_chain(
|
||||
std::string &&name,
|
||||
std::string &&author,
|
||||
bool transform,
|
||||
target_manager& targets,
|
||||
std::vector<bgfx_slider*> &&sliders,
|
||||
std::vector<bgfx_parameter*> &¶ms,
|
||||
std::vector<bgfx_chain_entry*> &&entries,
|
||||
std::vector<bgfx_target*> &&target_list,
|
||||
std::uint32_t screen_index)
|
||||
: m_name(std::move(name))
|
||||
, m_author(std::move(author))
|
||||
, m_transform(transform)
|
||||
, m_targets(targets)
|
||||
, m_sliders(sliders)
|
||||
, m_params(params)
|
||||
, m_entries(entries)
|
||||
, m_target_list(target_list)
|
||||
, m_sliders(std::move(sliders))
|
||||
, m_params(std::move(params))
|
||||
, m_entries(std::move(entries))
|
||||
, m_target_list(std::move(target_list))
|
||||
, m_current_time(0)
|
||||
, m_screen_index(screen_index)
|
||||
, m_has_converter(false)
|
||||
|
@ -27,7 +27,7 @@ class osd_window;
|
||||
class bgfx_chain
|
||||
{
|
||||
public:
|
||||
bgfx_chain(std::string name, std::string author, bool transform, target_manager& targets, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries, std::vector<bgfx_target*> target_list, uint32_t screen_index);
|
||||
bgfx_chain(std::string &&name, std::string &&author, bool transform, target_manager& targets, std::vector<bgfx_slider*> &&sliders, std::vector<bgfx_parameter*> &¶ms, std::vector<bgfx_chain_entry*> &&entries, std::vector<bgfx_target*> &&target_list, uint32_t screen_index);
|
||||
~bgfx_chain();
|
||||
|
||||
void process(chain_manager::screen_prim &prim, int view, int screen, texture_manager& textures, osd_window &window);
|
||||
|
@ -29,7 +29,13 @@
|
||||
#include "clear.h"
|
||||
#include "clearreader.h"
|
||||
|
||||
bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::string prefix, chain_manager& chains, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params, uint32_t screen_index)
|
||||
bgfx_chain_entry* chain_entry_reader::read_from_value(
|
||||
const Value &value,
|
||||
const std::string &prefix,
|
||||
chain_manager &chains,
|
||||
std::map<std::string, bgfx_slider*> &sliders,
|
||||
std::map<std::string, bgfx_parameter*> ¶ms,
|
||||
uint32_t screen_index)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -52,18 +58,18 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
||||
for (uint32_t i = 0; i < input_array.Size(); i++)
|
||||
{
|
||||
const Value& input = input_array[i];
|
||||
if (!READER_CHECK(input.HasMember("sampler"), (prefix + "input[" + std::to_string(i) + ": Must have string value 'sampler' (what sampler are we binding to?)\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(input["sampler"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'sampler' must be a string\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(input.HasMember("sampler"), "%sinput[%u]: Must have string value 'sampler' (what sampler are we binding to?)\n", prefix, i)) return nullptr;
|
||||
if (!READER_CHECK(input["sampler"].IsString(), "%sinput[%u]: Value 'sampler' must be a string\n", prefix, i)) return nullptr;
|
||||
bool has_texture = input.HasMember("texture");
|
||||
bool has_target = input.HasMember("target");
|
||||
bool has_option = input.HasMember("option");
|
||||
if (!READER_CHECK(has_texture || has_target || has_option, (prefix + "input[" + std::to_string(i) + ": Must have string value 'target', 'texture' or 'option' (what source are we using?)\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(!has_texture || input["texture"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'texture' must be a string\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(!has_target || input["target"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'target' must be a string\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(!has_option || input["option"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'option' must be a string\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(has_target || !input.HasMember("bilinear") || input["bilinear"].IsBool(), (prefix + "input[" + std::to_string(i) + ": Value 'bilinear' must be a boolean\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(has_target || !input.HasMember("clamp") || input["clamp"].IsBool(), (prefix + "input[" + std::to_string(i) + ": Value 'clamp' must be a boolean\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(has_texture || has_option || !input.HasMember("selection") || input["selection"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'selection' must be a string\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(has_texture || has_target || has_option, "%sinput[%u]: Must have string value 'target', 'texture' or 'option' (what source are we using?)\n", prefix, i)) return nullptr;
|
||||
if (!READER_CHECK(!has_texture || input["texture"].IsString(), "%sinput[%u]: Value 'texture' must be a string\n", prefix, i)) return nullptr;
|
||||
if (!READER_CHECK(!has_target || input["target"].IsString(), "%sinput[%u]: Value 'target' must be a string\n", prefix, i)) return nullptr;
|
||||
if (!READER_CHECK(!has_option || input["option"].IsString(), "%sinput[%u]: Value 'option' must be a string\n", prefix, i)) return nullptr;
|
||||
if (!READER_CHECK(has_target || !input.HasMember("bilinear") || input["bilinear"].IsBool(), "%sinput[%u]: Value 'bilinear' must be a boolean\n", prefix, i)) return nullptr;
|
||||
if (!READER_CHECK(has_target || !input.HasMember("clamp") || input["clamp"].IsBool(), "%sinput[%u]: Value 'clamp' must be a boolean\n", prefix, i)) return nullptr;
|
||||
if (!READER_CHECK(has_texture || has_option || !input.HasMember("selection") || input["selection"].IsString(), "%sinput[%u]: Value 'selection' must be a string\n", prefix, i)) return nullptr;
|
||||
bool bilinear = get_bool(input, "bilinear", true);
|
||||
bool clamp = get_bool(input, "clamp", false);
|
||||
std::string selection = get_string(input, "selection", "");
|
||||
@ -223,17 +229,17 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
||||
return new bgfx_chain_entry(name, effect, clear, suppressors, inputs, uniforms, chains.targets(), output, applytint);
|
||||
}
|
||||
|
||||
bool chain_entry_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool chain_entry_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(value.HasMember("effect"), (prefix + "Must have string value 'effect' (what effect does this entry use?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value["effect"].IsString(), (prefix + "Value 'effect' must be a string\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'effect' (what effect does this entry use?)\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("output"), (prefix + "Must have string value 'offset' (what target are we rendering to?)\n").c_str())) return false;
|
||||
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("applytint") || value["applytint"].IsBool(), (prefix + "Value 'applytint' must be a bool\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("effect"), "%sMust have string value 'effect' (what effect does this entry use?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["effect"].IsString(), "%sValue 'effect' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("name"), "%sMust have string value 'effect' (what effect does this entry use?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["name"].IsString(), "%sValue 'name' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("output"), "%sMust have string value 'offset' (what target are we rendering to?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["output"].IsString(), "%sValue 'output' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("input") || value["input"].IsArray(), "%sValue 'input' must be an array\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("uniforms") || value["uniforms"].IsArray(), "%sValue 'uniforms' must be an array\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("disablewhen") || value["disablewhen"].IsArray(), "%sValue 'disablewhen' must be an array\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("applytint") || value["applytint"].IsBool(), "%sValue 'applytint' must be a bool\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -5,15 +5,15 @@
|
||||
// chainentryreader.h - BGFX chain entry JSON reader
|
||||
//
|
||||
//============================================================
|
||||
#ifndef MAME_RENDER_BGFX_CHAINENTRYREADER_H
|
||||
#define MAME_RENDER_BGFX_CHAINENTRYREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_CHAIN_ENTRY_READER__
|
||||
#define __DRAWBGFX_CHAIN_ENTRY_READER__
|
||||
#include "statereader.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
class bgfx_chain_entry;
|
||||
class bgfx_slider;
|
||||
@ -23,10 +23,10 @@ class chain_manager;
|
||||
class chain_entry_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static bgfx_chain_entry* read_from_value(const Value& value, std::string prefix, chain_manager& chains, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params, uint32_t screen_index);
|
||||
static bgfx_chain_entry* read_from_value(const Value& value, const std::string &prefix, chain_manager& chains, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params, uint32_t screen_index);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_CHAIN_ENTRY_READER__
|
||||
#endif // MAME_RENDER_BGFX_CHAINENTRYREADER_H
|
||||
|
@ -8,21 +8,20 @@
|
||||
|
||||
#include "chainreader.h"
|
||||
|
||||
#include <string>
|
||||
#include "chain.h"
|
||||
#include "chainentryreader.h"
|
||||
#include "chainmanager.h"
|
||||
#include "parameter.h"
|
||||
#include "paramreader.h"
|
||||
#include "slider.h"
|
||||
#include "sliderreader.h"
|
||||
#include "targetmanager.h"
|
||||
#include "targetreader.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "chain.h"
|
||||
#include "chainmanager.h"
|
||||
#include "sliderreader.h"
|
||||
#include "paramreader.h"
|
||||
#include "chainentryreader.h"
|
||||
#include "targetreader.h"
|
||||
#include "targetmanager.h"
|
||||
#include "slider.h"
|
||||
#include "parameter.h"
|
||||
|
||||
bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix, chain_manager& chains, uint32_t screen_index, uint16_t user_prescale, uint16_t max_prescale_size)
|
||||
bgfx_chain* chain_reader::read_from_value(const Value& value, const std::string &prefix, chain_manager& chains, uint32_t screen_index, uint16_t user_prescale, uint16_t max_prescale_size)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -121,19 +120,28 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix
|
||||
}
|
||||
}
|
||||
|
||||
return new bgfx_chain(name, author, transform, chains.targets(), sliders, parameters, entries, target_list, screen_index);
|
||||
return new bgfx_chain(
|
||||
std::move(name),
|
||||
std::move(author),
|
||||
transform,
|
||||
chains.targets(),
|
||||
std::move(sliders),
|
||||
std::move(parameters),
|
||||
std::move(entries),
|
||||
std::move(target_list),
|
||||
screen_index);
|
||||
}
|
||||
|
||||
bool chain_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool chain_reader::validate_parameters(const Value& value, const 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;
|
||||
if (!READER_CHECK(value.HasMember("name"), "%sMust have string value 'name'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["name"].IsString(), "%sValue 'name' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("author"), "%sMust have string value 'author'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["author"].IsString(), "%sValue 'author' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("passes"), "%sMust have array value 'passes'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["passes"].IsArray(), "%sValue 'passes' must be an array\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("sliders") || value["sliders"].IsArray(), "%sValue 'sliders' must be an array\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("parameters") || value["parameters"].IsArray(), "%sValue 'parameters' must be an array\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("targets") || value["targets"].IsArray(), "%sValue 'targets' must be an array\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,23 +6,25 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_CHAINREADER_H
|
||||
#define MAME_RENDER_BGFX_CHAINREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_CHAIN_READER__
|
||||
#define __DRAWBGFX_CHAIN_READER__
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class bgfx_chain;
|
||||
class chain_manager;
|
||||
|
||||
class chain_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static bgfx_chain* read_from_value(const Value& value, std::string prefix, chain_manager& chains, uint32_t screen_index, uint16_t user_prescale, uint16_t max_prescale_size);
|
||||
static bgfx_chain* read_from_value(const Value& value, const std::string &prefix, chain_manager& chains, uint32_t screen_index, uint16_t user_prescale, uint16_t max_prescale_size);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_CHAIN_READER__
|
||||
#endif // MAME_RENDER_BGFX_CHAINREADER_H
|
||||
|
@ -6,13 +6,13 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
#include "clearreader.h"
|
||||
|
||||
#include "clear.h"
|
||||
|
||||
clear_state* clear_reader::read_from_value(const Value& value, std::string prefix)
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
clear_state* clear_reader::read_from_value(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -29,7 +29,7 @@ clear_state* clear_reader::read_from_value(const Value& value, std::string prefi
|
||||
const Value& colors = value["clearcolor"];
|
||||
for (int i = 0; i < colors.Size(); i++)
|
||||
{
|
||||
if (!READER_CHECK(colors[i].IsNumber(), (prefix + "clearcolor[" + std::to_string(i) + "] must be a numeric value\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(colors[i].IsNumber(), "%sclearcolor[%d] must be a numeric value\n", prefix, i)) return nullptr;
|
||||
auto val = int32_t(float(colors[i].GetDouble()) * 255.0f);
|
||||
if (val > 255) val = 255;
|
||||
if (val < 0) val = 0;
|
||||
@ -53,10 +53,10 @@ clear_state* clear_reader::read_from_value(const Value& value, std::string prefi
|
||||
return new clear_state(clear_flags, clear_color, clear_depth, clear_stencil);
|
||||
}
|
||||
|
||||
bool clear_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool clear_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(!value.HasMember("clearcolor") || (value["clearcolor"].IsArray() && value["clearcolor"].GetArray().Size() == 4), (prefix + "'clearcolor' must be an array of four numeric RGBA values representing the color to which to clear the color buffer\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("cleardepth") || value["cleardepth"].IsNumber(), (prefix + "'cleardepth' must be a numeric value representing the depth to which to clear the depth buffer\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("clearstencil") || value["clearstencil"].IsNumber(), (prefix + "'clearstencil' must be a numeric value representing the stencil value to which to clear the stencil buffer\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("clearcolor") || (value["clearcolor"].IsArray() && value["clearcolor"].GetArray().Size() == 4), "%s'clearcolor' must be an array of four numeric RGBA values representing the color to which to clear the color buffer\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("cleardepth") || value["cleardepth"].IsNumber(), "%s'cleardepth' must be a numeric value representing the depth to which to clear the depth buffer\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("clearstencil") || value["clearstencil"].IsNumber(), "%s'clearstencil' must be a numeric value representing the stencil value to which to clear the stencil buffer\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,26 +6,26 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_CLEARREADER_H
|
||||
#define MAME_RENDER_BGFX_CLEARREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_CLEAR_READER__
|
||||
#define __DRAWBGFX_CLEAR_READER__
|
||||
#include "statereader.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
class clear_state;
|
||||
|
||||
class clear_reader : public state_reader {
|
||||
public:
|
||||
static clear_state* read_from_value(const Value& value, std::string prefix);
|
||||
static clear_state* read_from_value(const Value& value, const std::string &prefix);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
|
||||
static const int FLAG_COUNT = 3;
|
||||
static const string_to_enum FLAG_NAMES[FLAG_COUNT];
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_CLEAR_READER__
|
||||
#endif // MAME_RENDER_BGFX_CLEARREADER_H
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
#include "depthreader.h"
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
const depth_reader::string_to_enum depth_reader::FUNCTION_NAMES[depth_reader::FUNCTION_COUNT] = {
|
||||
{ "never", BGFX_STATE_DEPTH_TEST_NEVER },
|
||||
{ "less", BGFX_STATE_DEPTH_TEST_LESS },
|
||||
@ -21,12 +21,12 @@ const depth_reader::string_to_enum depth_reader::FUNCTION_NAMES[depth_reader::FU
|
||||
{ "always", BGFX_STATE_DEPTH_TEST_ALWAYS }
|
||||
};
|
||||
|
||||
uint64_t depth_reader::read_from_value(const Value& value, std::string prefix)
|
||||
uint64_t depth_reader::read_from_value(const Value& value, const std::string &prefix)
|
||||
{
|
||||
uint64_t write_enable = 0;
|
||||
if (value.HasMember("writeenable"))
|
||||
{
|
||||
if (!READER_CHECK(value["writeenable"].IsBool(), (prefix + "Value 'writeenable' must be a boolean\n").c_str())) return 0;
|
||||
if (!READER_CHECK(value["writeenable"].IsBool(), "%sValue 'writeenable' must be a boolean\n", prefix)) return 0;
|
||||
write_enable = value["writeenable"].GetBool() ? BGFX_STATE_WRITE_Z : 0;
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_DEPTHREADER_H
|
||||
#define MAME_RENDER_BGFX_DEPTHREADER_H
|
||||
|
||||
#ifndef __DRAWBGFX_DEPTH_READER__
|
||||
#define __DRAWBGFX_DEPTH_READER__
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -17,11 +17,11 @@
|
||||
|
||||
class depth_reader : public state_reader {
|
||||
public:
|
||||
static uint64_t read_from_value(const Value& value, std::string prefix);
|
||||
static uint64_t read_from_value(const Value& value, const std::string &prefix);
|
||||
|
||||
private:
|
||||
static const int FUNCTION_COUNT = 8;
|
||||
static const string_to_enum FUNCTION_NAMES[FUNCTION_COUNT];
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_DEPTH_READER__
|
||||
#endif // MAME_RENDER_BGFX_DEPTHREADER_H
|
||||
|
@ -39,7 +39,7 @@ static bool prepare_effect_document(std::string &name, osd_options &options, rap
|
||||
bx::FileReader reader;
|
||||
if (!bx::open(&reader, path.c_str()))
|
||||
{
|
||||
osd_printf_error("Unable to open effect file %s\n", path.c_str());
|
||||
osd_printf_error("Unable to open effect file %s\n", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -57,8 +57,8 @@ static bool prepare_effect_document(std::string &name, osd_options &options, rap
|
||||
if (document.HasParseError())
|
||||
{
|
||||
std::string error(rapidjson::GetParseError_En(document.GetParseError()));
|
||||
osd_printf_error("Unable to parse effect %s. Errors returned:\n", path.c_str());
|
||||
osd_printf_error("%s\n", error.c_str());
|
||||
osd_printf_error("Unable to parse effect %s. Errors returned:\n", path);
|
||||
osd_printf_error("%s\n", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ bgfx_effect* effect_manager::load_effect(osd_options &options, std::string name)
|
||||
|
||||
if (effect == nullptr)
|
||||
{
|
||||
osd_printf_error("Unable to load effect %s\n", name.c_str());
|
||||
osd_printf_error("Unable to load effect %s\n", name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "uniformreader.h"
|
||||
#include "uniform.h"
|
||||
|
||||
bgfx_effect *effect_reader::read_from_value(std::string name, const Value& value, std::string prefix, osd_options &options, shader_manager& shaders)
|
||||
bgfx_effect *effect_reader::read_from_value(std::string name, const Value& value, const std::string &prefix, osd_options &options, shader_manager& shaders)
|
||||
{
|
||||
uint64_t flags = 0;
|
||||
std::string vertex_name;
|
||||
@ -48,7 +48,7 @@ bgfx_effect *effect_reader::read_from_value(std::string name, const Value& value
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool effect_reader::validate_value(const Value& value, std::string prefix, osd_options &options)
|
||||
bool effect_reader::validate_value(const Value& value, const std::string &prefix, osd_options &options)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -80,7 +80,7 @@ bool effect_reader::validate_value(const Value& value, std::string prefix, osd_o
|
||||
return true;
|
||||
}
|
||||
|
||||
bool effect_reader::get_base_effect_data(const Value& value, std::string &prefix, uint64_t &flags, std::string &vertex_name, std::string &fragment_name,
|
||||
bool effect_reader::get_base_effect_data(const Value& value, const std::string &prefix, uint64_t &flags, std::string &vertex_name, std::string &fragment_name,
|
||||
std::vector<bgfx_uniform *> &uniforms)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
@ -153,17 +153,17 @@ void effect_reader::clear_uniform_list(std::vector<bgfx_uniform *> &uniforms)
|
||||
}
|
||||
}
|
||||
|
||||
bool effect_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool effect_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(value.HasMember("depth"), (prefix + "Must have object value 'depth' (what are our Z-buffer settings?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("cull"), (prefix + "Must have object value 'cull' (do we cull triangles based on winding?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("write"), (prefix + "Must have object value 'write' (what are our color buffer write settings?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("vertex"), (prefix + "Must have string value 'vertex' (what is our vertex shader?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value["vertex"].IsString(), (prefix + "Value 'vertex' must be a string\n").c_str())) return false;
|
||||
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;
|
||||
if (!READER_CHECK(!value.HasMember("fragment") || value["fragment"].IsString(), (prefix + "Value 'fragment' must be a string\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("pixel") || value["pixel"].IsString(), (prefix + "Value 'pixel' must be a string\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("uniforms"), (prefix + "Must have array value 'uniforms' (what are our shader's parameters?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value["uniforms"].IsArray(), (prefix + "Value 'uniforms' must be an array\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("depth"), "%sMust have object value 'depth' (what are our Z-buffer settings?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("cull"), "%sMust have object value 'cull' (do we cull triangles based on winding?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("write"), "%sMust have object value 'write' (what are our color buffer write settings?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("vertex"), "%sMust have string value 'vertex' (what is our vertex shader?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["vertex"].IsString(), "%sValue 'vertex' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("fragment") || value.HasMember("pixel"), "%sMust have string value named 'fragment' or 'pixel' (what is our fragment/pixel shader?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("fragment") || value["fragment"].IsString(), "%sValue 'fragment' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("pixel") || value["pixel"].IsString(), "%sValue 'pixel' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("uniforms"), "%sMust have array value 'uniforms' (what are our shader's parameters?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["uniforms"].IsArray(), "%sValue 'uniforms' must be an array\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_EFFECTREADER_H
|
||||
#define MAME_RENDER_BGFX_EFFECTREADER_H
|
||||
|
||||
#ifndef __DRAWBGFX_EFFECT_READER__
|
||||
#define __DRAWBGFX_EFFECT_READER__
|
||||
#pragma once
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
@ -26,16 +26,16 @@ class shader_manager;
|
||||
class effect_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static bgfx_effect *read_from_value(std::string name, const Value& value, std::string prefix, osd_options &options, shader_manager& shaders);
|
||||
static bool validate_value(const Value& value, std::string prefix, osd_options &options);
|
||||
static bgfx_effect *read_from_value(std::string name, const Value& value, const std::string &prefix, osd_options &options, shader_manager& shaders);
|
||||
static bool validate_value(const Value& value, const std::string &prefix, osd_options &options);
|
||||
|
||||
private:
|
||||
static bool get_base_effect_data(const Value& value, std::string &prefix, uint64_t &flags, std::string &vertex_name, std::string &fragment_name,
|
||||
static bool get_base_effect_data(const Value& value, const std::string &prefix, uint64_t &flags, std::string &vertex_name, std::string &fragment_name,
|
||||
std::vector<bgfx_uniform *> &uniforms);
|
||||
static bool get_shader_data(const Value& value, osd_options &options, shader_manager &shaders, std::string &vertex_name, bgfx::ShaderHandle &vertex_shader,
|
||||
std::string &fragment_name, bgfx::ShaderHandle &fragment_shader);
|
||||
static void clear_uniform_list(std::vector<bgfx_uniform *> &uniforms);
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_EFFECT_READER__
|
||||
#endif // MAME_RENDER_BGFX_EFFECTREADER_H
|
||||
|
@ -9,15 +9,15 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_ENTRYUNIFORM_H
|
||||
#define MAME_RENDER_BGFX_ENTRYUNIFORM_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef DRAWBGFX_ENTRY_UNIFORM
|
||||
#define DRAWBGFX_ENTRY_UNIFORM
|
||||
#include "uniform.h"
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
#include "uniform.h"
|
||||
|
||||
class bgfx_entry_uniform
|
||||
{
|
||||
public:
|
||||
@ -25,10 +25,10 @@ public:
|
||||
virtual ~bgfx_entry_uniform() { }
|
||||
|
||||
virtual void bind() = 0;
|
||||
std::string name() const { return m_uniform->name(); }
|
||||
const std::string &name() const { return m_uniform->name(); }
|
||||
|
||||
protected:
|
||||
bgfx_uniform* m_uniform;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_ENTRY_UNIFORM__
|
||||
#endif // MAME_RENDER_BGFX_ENTRYUNIFORM_H
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "paramuniformreader.h"
|
||||
#include "uniform.h"
|
||||
|
||||
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, const std::string &prefix, bgfx_effect* effect, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -25,7 +25,7 @@ bgfx_entry_uniform* entry_uniform_reader::read_from_value(const Value& value, st
|
||||
std::string name = value["uniform"].GetString();
|
||||
bgfx_uniform* uniform = effect->uniform(name);
|
||||
|
||||
if (!READER_CHECK(uniform != nullptr, (prefix + "Uniform '" + name + " does not appear to exist\n").c_str()))
|
||||
if (!READER_CHECK(uniform != nullptr, "%sUniform '%s' does not appear to exist\n", prefix, name))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@ -44,16 +44,16 @@ bgfx_entry_uniform* entry_uniform_reader::read_from_value(const Value& value, st
|
||||
}
|
||||
else
|
||||
{
|
||||
READER_CHECK(false, (prefix + "Unrecognized uniform type for uniform binding " + name).c_str());
|
||||
READER_CHECK(false, "%sUnrecognized uniform type for uniform binding %s", prefix, name);
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool entry_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool entry_uniform_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(value.HasMember("uniform"), (prefix + "Must have string value 'uniform' (what uniform are we mapping?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value["uniform"].IsString(), (prefix + "Value 'effect' must be a string\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("uniform"), "%sMust have string value 'uniform' (what uniform are we mapping?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["uniform"].IsString(), "%sValue 'effect' must be a string\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,16 +6,16 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_ENTRYUNIFORMREADER_H
|
||||
#define MAME_RENDER_BGFX_ENTRYUNIFORMREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_ENTRY_UNIFORM_READER__
|
||||
#define __DRAWBGFX_ENTRY_UNIFORM_READER__
|
||||
#include "statereader.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
class bgfx_entry_uniform;
|
||||
class bgfx_slider;
|
||||
class bgfx_effect;
|
||||
@ -24,10 +24,10 @@ class bgfx_parameter;
|
||||
class entry_uniform_reader : public state_reader
|
||||
{
|
||||
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, const std::string &prefix, bgfx_effect* effect, std::map<std::string, bgfx_slider*>& sliders, std::map<std::string, bgfx_parameter*>& params);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_ENTRY_UNIFORM_READER__
|
||||
#endif // MAME_RENDER_BGFX_ENTRYUNIFORMREADER_H
|
||||
|
@ -8,8 +8,10 @@
|
||||
|
||||
#include "frameparameter.h"
|
||||
|
||||
bgfx_frame_parameter::bgfx_frame_parameter(std::string name, parameter_type type, uint32_t period)
|
||||
: bgfx_parameter(name, type)
|
||||
#include <utility>
|
||||
|
||||
bgfx_frame_parameter::bgfx_frame_parameter(std::string &&name, parameter_type type, uint32_t period)
|
||||
: bgfx_parameter(std::move(name), type)
|
||||
, m_current_frame(0)
|
||||
, m_period(period)
|
||||
{
|
||||
@ -20,7 +22,7 @@ float bgfx_frame_parameter::value()
|
||||
return float(m_current_frame);
|
||||
}
|
||||
|
||||
void bgfx_frame_parameter::tick(double /*delta*/)
|
||||
void bgfx_frame_parameter::tick(double delta)
|
||||
{
|
||||
m_current_frame++;
|
||||
m_current_frame %= m_period;
|
||||
|
@ -6,22 +6,19 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_FRAMEPARAMETER_H
|
||||
#define MAME_RENDER_BGFX_FRAMEPARAMETER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_FRAME_PARAMETER__
|
||||
#define __DRAWBGFX_FRAME_PARAMETER__
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
#include "parameter.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "parameter.h"
|
||||
|
||||
class bgfx_frame_parameter : public bgfx_parameter
|
||||
{
|
||||
public:
|
||||
bgfx_frame_parameter(std::string name, parameter_type type, uint32_t period);
|
||||
virtual ~bgfx_frame_parameter() { }
|
||||
bgfx_frame_parameter(std::string &&name, parameter_type type, uint32_t period);
|
||||
|
||||
virtual float value() override;
|
||||
virtual void tick(double delta) override;
|
||||
@ -31,4 +28,4 @@ private:
|
||||
uint32_t m_period;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_FRAME_PARAMETER__
|
||||
#endif // MAME_RENDER_BGFX_FRAMEPARAMETER_H
|
||||
|
@ -10,12 +10,13 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_PARAMETER_H
|
||||
#define MAME_RENDER_BGFX_PARAMETER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_PARAMETER__
|
||||
#define __DRAWBGFX_PARAMETER__
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
class bgfx_parameter
|
||||
{
|
||||
@ -27,18 +28,18 @@ public:
|
||||
PARAM_TIME
|
||||
};
|
||||
|
||||
bgfx_parameter(std::string name, parameter_type type) : m_name(name), m_type(type) { }
|
||||
virtual ~bgfx_parameter() { }
|
||||
bgfx_parameter(std::string &&name, parameter_type type) : m_name(std::move(name)), m_type(type) { }
|
||||
virtual ~bgfx_parameter() = default;
|
||||
|
||||
virtual void tick(double delta) = 0;
|
||||
|
||||
// Getters
|
||||
virtual float value() = 0;
|
||||
std::string name() const { return m_name; }
|
||||
const std::string &name() const { return m_name; }
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
parameter_type m_type;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_PARAMETER__
|
||||
#endif // MAME_RENDER_BGFX_PARAMETER_H
|
||||
|
@ -6,15 +6,13 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "paramreader.h"
|
||||
|
||||
#include "parameter.h"
|
||||
#include "frameparameter.h"
|
||||
#include "windowparameter.h"
|
||||
#include "timeparameter.h"
|
||||
#include "chainmanager.h"
|
||||
#include "frameparameter.h"
|
||||
#include "parameter.h"
|
||||
#include "timeparameter.h"
|
||||
#include "windowparameter.h"
|
||||
|
||||
const parameter_reader::string_to_enum parameter_reader::TYPE_NAMES[parameter_reader::TYPE_COUNT] = {
|
||||
{ "frame", bgfx_parameter::parameter_type::PARAM_FRAME },
|
||||
@ -22,7 +20,7 @@ const parameter_reader::string_to_enum parameter_reader::TYPE_NAMES[parameter_re
|
||||
{ "time", bgfx_parameter::parameter_type::PARAM_TIME }
|
||||
};
|
||||
|
||||
bgfx_parameter* parameter_reader::read_from_value(const Value& value, std::string prefix, chain_manager& chains)
|
||||
bgfx_parameter* parameter_reader::read_from_value(const Value& value, const std::string &prefix, chain_manager& chains)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -35,32 +33,32 @@ bgfx_parameter* parameter_reader::read_from_value(const Value& value, std::strin
|
||||
if (type == bgfx_parameter::parameter_type::PARAM_FRAME)
|
||||
{
|
||||
uint32_t period = int(value["period"].GetDouble());
|
||||
return new bgfx_frame_parameter(name, type, period);
|
||||
return new bgfx_frame_parameter(std::move(name), type, period);
|
||||
}
|
||||
else if (type == bgfx_parameter::parameter_type::PARAM_WINDOW)
|
||||
{
|
||||
return new bgfx_window_parameter(name, type, chains.window_index());
|
||||
return new bgfx_window_parameter(std::move(name), type, chains.window_index());
|
||||
}
|
||||
else if (type == bgfx_parameter::parameter_type::PARAM_TIME)
|
||||
{
|
||||
auto limit = float(value["limit"].GetDouble());
|
||||
return new bgfx_time_parameter(name, type, limit);
|
||||
return new bgfx_time_parameter(std::move(name), type, limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
READER_CHECK(false, (prefix + "Unknown parameter type '" + std::string(value["type"].GetString()) + "'\n").c_str());
|
||||
READER_CHECK(false, "%sUnknown parameter type '%s'\n", prefix, value["type"].GetString());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool parameter_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool parameter_reader::validate_parameters(const Value& value, const 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("type"), (prefix + "Must have string value 'type'\n").c_str())) return false;
|
||||
if (!READER_CHECK(value["type"].IsString(), (prefix + "Value 'type' must be a string\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("period") || value["period"].IsNumber(), (prefix + "Value 'period' must be numeric\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("limit") || value["limit"].IsNumber(), (prefix + "Value 'period' must be numeric\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("name"), "%sMust have string value 'name'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["name"].IsString(), "%sValue 'name' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("type"), "%sMust have string value 'type'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["type"].IsString(), "%sValue 'type' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("period") || value["period"].IsNumber(), "%sValue 'period' must be numeric\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("limit") || value["limit"].IsNumber(), "%sValue 'period' must be numeric\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,26 +6,28 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_PARAMREADER_H
|
||||
#define MAME_RENDER_BGFX_PARAMREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_PARAM_READER__
|
||||
#define __DRAWBGFX_PARAM_READER__
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class bgfx_parameter;
|
||||
class chain_manager;
|
||||
|
||||
class parameter_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static bgfx_parameter* read_from_value(const Value& value, std::string prefix, chain_manager& chains);
|
||||
static bgfx_parameter* read_from_value(const Value& value, const std::string &prefix, chain_manager& chains);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
|
||||
static const int TYPE_COUNT = 3;
|
||||
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_PARAM_READER__
|
||||
#endif // MAME_RENDER_BGFX_PARAMREADER_H
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_PARAMUNIFORM_H
|
||||
#define MAME_RENDER_BGFX_PARAMUNIFORM_H
|
||||
|
||||
#ifndef __DRAWBGFX_PARAM_UNIFORM__
|
||||
#define __DRAWBGFX_PARAM_UNIFORM__
|
||||
#pragma once
|
||||
|
||||
#include "entryuniform.h"
|
||||
|
||||
@ -26,4 +26,4 @@ private:
|
||||
bgfx_parameter* m_param;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_PARAM_UNIFORM__
|
||||
#endif // MAME_RENDER_BGFX_PARAMUNIFORM_H
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include "paramuniformreader.h"
|
||||
|
||||
#include "entryuniform.h"
|
||||
#include "paramuniform.h"
|
||||
#include "parameter.h"
|
||||
#include "paramuniform.h"
|
||||
|
||||
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, const std::string &prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_parameter*>& params)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -24,9 +24,9 @@ bgfx_entry_uniform* param_uniform_reader::read_from_value(const Value& value, st
|
||||
return new bgfx_param_uniform(uniform, params[parameter]);
|
||||
}
|
||||
|
||||
bool param_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool param_uniform_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(value.HasMember("parameter"), (prefix + "Must have string value 'parameter' (what parameter is being mapped?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value["parameter"].IsString(), (prefix + "Value 'parameter' must be a string\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("parameter"), "%sMust have string value 'parameter' (what parameter is being mapped?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["parameter"].IsString(), "%sValue 'parameter' must be a string\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,16 +6,16 @@
|
||||
//
|
||||
//==================================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_PARAMUNIFORMREADER_H
|
||||
#define MAME_RENDER_BGFX_PARAMUNIFORMREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_PARAM_UNIFORM_READER__
|
||||
#define __DRAWBGFX_PARAM_UNIFORM_READER__
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class bgfx_entry_uniform;
|
||||
class bgfx_uniform;
|
||||
class bgfx_parameter;
|
||||
@ -23,10 +23,10 @@ class bgfx_parameter;
|
||||
class param_uniform_reader : public state_reader
|
||||
{
|
||||
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, const std::string &prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_parameter*>& params);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_PARAM_UNIFORM_READER__
|
||||
#endif // MAME_RENDER_BGFX_PARAMUNIFORMREADER_H
|
||||
|
@ -31,7 +31,7 @@ shader_manager::~shader_manager()
|
||||
m_shaders.clear();
|
||||
}
|
||||
|
||||
bgfx::ShaderHandle shader_manager::get_or_load_shader(osd_options &options, std::string name)
|
||||
bgfx::ShaderHandle shader_manager::get_or_load_shader(osd_options &options, const std::string &name)
|
||||
{
|
||||
std::map<std::string, bgfx::ShaderHandle>::iterator iter = m_shaders.find(name);
|
||||
if (iter != m_shaders.end())
|
||||
@ -48,7 +48,7 @@ bgfx::ShaderHandle shader_manager::get_or_load_shader(osd_options &options, std:
|
||||
return handle;
|
||||
}
|
||||
|
||||
bgfx::ShaderHandle shader_manager::load_shader(osd_options &options, std::string name)
|
||||
bgfx::ShaderHandle shader_manager::load_shader(osd_options &options, const std::string &name)
|
||||
{
|
||||
std::string shader_path = make_path_string(options, name);
|
||||
const bgfx::Memory* mem = load_mem(shader_path + name + ".bin");
|
||||
@ -60,7 +60,7 @@ bgfx::ShaderHandle shader_manager::load_shader(osd_options &options, std::string
|
||||
return BGFX_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
bool shader_manager::is_shader_present(osd_options &options, std::string name)
|
||||
bool shader_manager::is_shader_present(osd_options &options, const std::string &name)
|
||||
{
|
||||
std::string shader_path = make_path_string(options, name);
|
||||
std::string file_name = shader_path + name + ".bin";
|
||||
@ -80,7 +80,7 @@ bool shader_manager::is_shader_present(osd_options &options, std::string name)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string shader_manager::make_path_string(osd_options &options, std::string name)
|
||||
std::string shader_manager::make_path_string(osd_options &options, const std::string &name)
|
||||
{
|
||||
std::string shader_path(options.bgfx_path());
|
||||
shader_path += PATH_SEPARATOR "shaders" PATH_SEPARATOR;
|
||||
@ -123,7 +123,7 @@ std::string shader_manager::make_path_string(osd_options &options, std::string n
|
||||
return shader_path;
|
||||
}
|
||||
|
||||
const bgfx::Memory* shader_manager::load_mem(std::string name)
|
||||
const bgfx::Memory* shader_manager::load_mem(const std::string &name)
|
||||
{
|
||||
bx::FileReader reader;
|
||||
if (bx::open(&reader, name.c_str()))
|
||||
@ -139,7 +139,7 @@ const bgfx::Memory* shader_manager::load_mem(std::string name)
|
||||
}
|
||||
else
|
||||
{
|
||||
osd_printf_error("Unable to load shader %s\n", name.c_str());
|
||||
osd_printf_error("Unable to load shader %s\n", name);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_SHADERMANAGER_H
|
||||
#define MAME_RENDER_BGFX_SHADERMANAGER_H
|
||||
|
||||
#ifndef __DRAWBGFX_SHADER_MANAGER__
|
||||
#define __DRAWBGFX_SHADER_MANAGER__
|
||||
#pragma once
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
@ -28,15 +28,15 @@ public:
|
||||
~shader_manager();
|
||||
|
||||
// Getters
|
||||
bgfx::ShaderHandle get_or_load_shader(osd_options &options, std::string name);
|
||||
static bgfx::ShaderHandle load_shader(osd_options &options, std::string name);
|
||||
static bool is_shader_present(osd_options &options, std::string name);
|
||||
bgfx::ShaderHandle get_or_load_shader(osd_options &options, const std::string &name);
|
||||
static bgfx::ShaderHandle load_shader(osd_options &options, const std::string &name);
|
||||
static bool is_shader_present(osd_options &options, const std::string &name);
|
||||
|
||||
private:
|
||||
static std::string make_path_string(osd_options &options, std::string name);
|
||||
static const bgfx::Memory* load_mem(std::string name);
|
||||
static std::string make_path_string(osd_options &options, const std::string &name);
|
||||
static const bgfx::Memory* load_mem(const std::string &name);
|
||||
|
||||
std::map<std::string, bgfx::ShaderHandle> m_shaders;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_SHADER_MANAGER__
|
||||
#endif // MAME_RENDER_BGFX_SHADERMANAGER_H
|
||||
|
@ -25,7 +25,7 @@ void main()
|
||||
{
|
||||
// previously this pass was applied two times with offsets of 0.25, 0.5, 0.75, 1.0
|
||||
// now this pass is applied only once with offsets of 0.25, 0.55, 1.0, 1.6 to achieve the same appearance as before till a maximum defocus of 2.0
|
||||
// 0.075xイ + 0.225x + 0.25
|
||||
// 0.075x² + 0.225x + 0.25
|
||||
const vec2 Coord1Offset = vec2(-1.60, 0.25);
|
||||
const vec2 Coord2Offset = vec2(-1.00, -0.55);
|
||||
const vec2 Coord3Offset = vec2(-0.55, 1.00);
|
||||
|
@ -18,11 +18,11 @@ uniform vec4 u_tex_size0;
|
||||
|
||||
SAMPLER2D(s_p, 0);
|
||||
|
||||
/*
|
||||
/*
|
||||
This is an approximation of Jinc(x)*Jinc(x*r1/r2) for x < 2.5,
|
||||
where r1 and r2 are the first two zeros of jinc function.
|
||||
For a jinc 2-lobe best approximation, use A=0.5 and B=0.825.
|
||||
*/
|
||||
*/
|
||||
|
||||
// A=0.5, B=0.825 is the best jinc approximation for x<2.5. if B=1.0, it's a lanczos filter.
|
||||
// Increase A to get more blur. Decrease it to get a sharper picture.
|
||||
|
@ -11,8 +11,10 @@
|
||||
|
||||
#include "strformat.h"
|
||||
|
||||
bgfx_slider::bgfx_slider(running_machine &machine, std::string name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector<std::string>& strings)
|
||||
: m_name(name)
|
||||
#include <utility>
|
||||
|
||||
bgfx_slider::bgfx_slider(running_machine &machine, std::string &&name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector<std::string>& strings)
|
||||
: m_name(std::move(name))
|
||||
, m_step(step)
|
||||
, m_type(type)
|
||||
, m_screen_type(screen)
|
||||
|
@ -46,13 +46,13 @@ public:
|
||||
SLIDER_SCREEN_TYPE_ANY = SLIDER_SCREEN_TYPE_RASTER | SLIDER_SCREEN_TYPE_VECTOR | SLIDER_SCREEN_TYPE_LCD
|
||||
};
|
||||
|
||||
bgfx_slider(running_machine& machine, std::string name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector<std::string>& strings);
|
||||
bgfx_slider(running_machine& machine, std::string &&name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector<std::string>& strings);
|
||||
virtual ~bgfx_slider();
|
||||
|
||||
int32_t update(std::string *str, int32_t newval);
|
||||
|
||||
// Getters
|
||||
std::string name() const { return m_name; }
|
||||
const std::string &name() const { return m_name; }
|
||||
slider_type type() const { return m_type; }
|
||||
float value() const { return m_value; }
|
||||
float uniform_value() const { return float(m_value); }
|
||||
|
@ -33,7 +33,7 @@ const slider_reader::string_to_enum slider_reader::SCREEN_NAMES[slider_reader::S
|
||||
{ "all", uint64_t(bgfx_slider::screen_type::SLIDER_SCREEN_TYPE_ANY) }
|
||||
};
|
||||
|
||||
std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std::string prefix, chain_manager& chains, uint32_t screen_index)
|
||||
std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, const std::string &prefix, chain_manager& chains, uint32_t screen_index)
|
||||
{
|
||||
std::vector<bgfx_slider*> sliders;
|
||||
|
||||
@ -55,7 +55,7 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
||||
const Value& string_array = value["strings"];
|
||||
for (uint32_t i = 0; i < string_array.Size(); i++)
|
||||
{
|
||||
if (!READER_CHECK(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(), "%sSlider '%s': strings[%u]: must be a string\n", prefix, name, i))
|
||||
{
|
||||
return sliders;
|
||||
}
|
||||
@ -117,32 +117,31 @@ std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std
|
||||
desc = prefixed_desc + "Invalid";
|
||||
break;
|
||||
}
|
||||
sliders.push_back(new bgfx_slider(chains.machine(), full_name, min[index], defaults[index], max[index], step, type, screen_type, format, desc, strings));
|
||||
sliders.push_back(new bgfx_slider(chains.machine(), std::move(full_name), min[index], defaults[index], max[index], step, type, screen_type, format, desc, strings));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float min = get_float(value, "min", 0.0f);
|
||||
float def = get_float(value, "default", 0.0f);
|
||||
float max = get_float(value, "max", 1.0f);
|
||||
const float min = get_float(value, "min", 0.0f);
|
||||
const float def = get_float(value, "default", 0.0f);
|
||||
const float max = get_float(value, "max", 1.0f);
|
||||
sliders.push_back(new bgfx_slider(chains.machine(), name + "0", min, def, max, step, type, screen_type, format, prefixed_desc, strings));
|
||||
}
|
||||
return sliders;
|
||||
}
|
||||
|
||||
bool slider_reader::get_values(const Value& value, std::string prefix, std::string name, float* values, const int count)
|
||||
bool slider_reader::get_values(const Value& value, const std::string &prefix, const std::string &name, float* values, const int count)
|
||||
{
|
||||
const char* name_str = name.c_str();
|
||||
const Value& value_array = value[name_str];
|
||||
const Value& value_array = value[name.c_str()];
|
||||
for (uint32_t i = 0; i < value_array.Size() && i < count; i++)
|
||||
{
|
||||
if (!READER_CHECK(value_array[i].IsNumber(), (prefix + "Entry " + std::to_string(i) + " must be a number\n").c_str())) return false;
|
||||
if (!READER_CHECK(value_array[i].IsNumber(), "%sEntry %u must be a number\n", prefix, i)) return false;
|
||||
values[i] = value_array[i].GetFloat();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool slider_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool slider_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(value.HasMember("name"), "%1$sMust have string value 'name'", prefix)) return false;
|
||||
if (!READER_CHECK(value["name"].IsString(), "%1$sValue 'name' must be a string", prefix)) return false;
|
||||
|
@ -6,26 +6,26 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_SLIDERREADER_H
|
||||
#define MAME_RENDER_BGFX_SLIDERREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_SLIDER_READER__
|
||||
#define __DRAWBGFX_SLIDER_READER__
|
||||
#include "statereader.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
class bgfx_slider;
|
||||
class chain_manager;
|
||||
|
||||
class slider_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static std::vector<bgfx_slider*> read_from_value(const Value& value, std::string prefix, chain_manager& chains, uint32_t screen_index);
|
||||
static std::vector<bgfx_slider*> read_from_value(const Value& value, const std::string &prefix, chain_manager& chains, uint32_t screen_index);
|
||||
|
||||
private:
|
||||
static bool get_values(const Value& value, std::string prefix, std::string name, float* values, const int count);
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool get_values(const Value& value, const std::string &prefix, const std::string &name, float* values, const int count);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
|
||||
static const int TYPE_COUNT = 5;
|
||||
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
||||
@ -33,4 +33,4 @@ private:
|
||||
static const string_to_enum SCREEN_NAMES[SCREEN_COUNT];
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_SLIDER_READER__
|
||||
#endif // MAME_RENDER_BGFX_SLIDERREADER_H
|
||||
|
@ -13,13 +13,12 @@
|
||||
|
||||
#include "slider.h"
|
||||
|
||||
bgfx_slider_uniform::bgfx_slider_uniform(bgfx_uniform* uniform, std::vector<bgfx_slider*> sliders)
|
||||
#include <utility>
|
||||
|
||||
bgfx_slider_uniform::bgfx_slider_uniform(bgfx_uniform* uniform, std::vector<bgfx_slider*> &&sliders)
|
||||
: bgfx_entry_uniform(uniform)
|
||||
, m_sliders(std::move(sliders))
|
||||
{
|
||||
for (bgfx_slider* slider : sliders)
|
||||
{
|
||||
m_sliders.push_back(slider);
|
||||
}
|
||||
}
|
||||
|
||||
void bgfx_slider_uniform::bind()
|
||||
|
@ -9,10 +9,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_SLIDERUNIFORM_H
|
||||
#define MAME_RENDER_BGFX_SLIDERUNIFORM_H
|
||||
|
||||
#ifndef __DRAWBGFX_SLIDER_UNIFORM__
|
||||
#define __DRAWBGFX_SLIDER_UNIFORM__
|
||||
#pragma once
|
||||
|
||||
#include "entryuniform.h"
|
||||
|
||||
@ -23,7 +23,7 @@ class bgfx_slider;
|
||||
class bgfx_slider_uniform : public bgfx_entry_uniform
|
||||
{
|
||||
public:
|
||||
bgfx_slider_uniform(bgfx_uniform* uniform, std::vector<bgfx_slider*> sliders);
|
||||
bgfx_slider_uniform(bgfx_uniform* uniform, std::vector<bgfx_slider*> &&sliders);
|
||||
|
||||
virtual void bind() override;
|
||||
|
||||
@ -31,4 +31,4 @@ private:
|
||||
std::vector<bgfx_slider*> m_sliders;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_SLIDER_UNIFORM__
|
||||
#endif // MAME_RENDER_BGFX_SLIDERUNIFORM_H
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
#include "slideruniformreader.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "slideruniform.h"
|
||||
#include "entryuniform.h"
|
||||
#include "slider.h"
|
||||
#include "slideruniform.h"
|
||||
|
||||
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)
|
||||
#include <vector>
|
||||
|
||||
bgfx_entry_uniform* slider_uniform_reader::read_from_value(const Value& value, const std::string &prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_slider*>& sliders)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -35,12 +35,12 @@ bgfx_entry_uniform* slider_uniform_reader::read_from_value(const Value& value, s
|
||||
slider_list.push_back(sliders[name + "2"]);
|
||||
}
|
||||
|
||||
return new bgfx_slider_uniform(uniform, slider_list);
|
||||
return new bgfx_slider_uniform(uniform, std::move(slider_list));
|
||||
}
|
||||
|
||||
bool slider_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool slider_uniform_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
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;
|
||||
if (!READER_CHECK(value["slider"].IsString(), (prefix + "Value 'slider' must be a string\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("slider"), "%sMust have string value 'slider' (what slider are we getting the value of?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["slider"].IsString(), "%sValue 'slider' must be a string\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,27 +6,27 @@
|
||||
//
|
||||
//================================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_SLIDERUNIFORMREADER_H
|
||||
#define MAME_RENDER_BGFX_SLIDERUNIFORMREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_SLIDER_UNIFORM_READER__
|
||||
#define __DRAWBGFX_SLIDER_UNIFORM_READER__
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "entryuniform.h"
|
||||
#include "statereader.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
class bgfx_uniform;
|
||||
class bgfx_slider;
|
||||
|
||||
class slider_uniform_reader : public state_reader
|
||||
{
|
||||
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, const std::string &prefix, bgfx_uniform* uniform, std::map<std::string, bgfx_slider*>& sliders);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_SLIDER_UNIFORM_READER__
|
||||
#endif // MAME_RENDER_BGFX_SLIDERUNIFORMREADER_H
|
||||
|
@ -13,13 +13,13 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
bgfx_suppressor::bgfx_suppressor(std::vector<bgfx_slider*> sliders, uint32_t condition, combine_mode combine, void* value)
|
||||
: m_sliders(sliders)
|
||||
bgfx_suppressor::bgfx_suppressor(std::vector<bgfx_slider*> &&sliders, uint32_t condition, combine_mode combine, void* value)
|
||||
: m_sliders(std::move(sliders))
|
||||
, m_condition(condition)
|
||||
, m_combine(combine)
|
||||
, m_value(nullptr)
|
||||
{
|
||||
uint32_t size = sliders[0]->size();
|
||||
uint32_t size = m_sliders[0]->size();
|
||||
m_value = new uint8_t[size];
|
||||
memcpy(m_value, value, size);
|
||||
}
|
||||
|
@ -7,10 +7,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_SUPPRESSOR_H
|
||||
#define MAME_RENDER_BGFX_SUPPRESSOR_H
|
||||
|
||||
#ifndef __DRAWBGFX_SUPPRESSOR__
|
||||
#define __DRAWBGFX_SUPPRESSOR__
|
||||
#pragma once
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
@ -34,7 +34,7 @@ public:
|
||||
COMBINE_OR
|
||||
};
|
||||
|
||||
bgfx_suppressor(std::vector<bgfx_slider*> sliders, uint32_t condition, combine_mode combine, void* value);
|
||||
bgfx_suppressor(std::vector<bgfx_slider*> &&sliders, uint32_t condition, combine_mode combine, void* value);
|
||||
~bgfx_suppressor();
|
||||
|
||||
// Getters
|
||||
@ -48,4 +48,4 @@ private:
|
||||
uint8_t* m_value;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_SUPPRESSOR__
|
||||
#endif // MAME_RENDER_BGFX_SUPPRESSOR_H
|
||||
|
@ -21,7 +21,7 @@ const suppressor_reader::string_to_enum suppressor_reader::COMBINE_NAMES[suppres
|
||||
{ "or", bgfx_suppressor::combine_mode::COMBINE_OR }
|
||||
};
|
||||
|
||||
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, const std::string &prefix, std::map<std::string, bgfx_slider*>& sliders)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -58,7 +58,7 @@ bgfx_suppressor* suppressor_reader::read_from_value(const Value& value, std::str
|
||||
if (slider_count > 1)
|
||||
{
|
||||
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;
|
||||
if (!READER_CHECK(slider_count == value["value"].GetArray().Size(), "%sExpected %d values, got %u\n", prefix, slider_count, value["value"].GetArray().Size())) return nullptr;
|
||||
for (int index = 1; index < slider_count; index++)
|
||||
{
|
||||
check_sliders.push_back(sliders[name + std::to_string(index)]);
|
||||
@ -69,26 +69,25 @@ bgfx_suppressor* suppressor_reader::read_from_value(const Value& value, std::str
|
||||
values[0] = get_int(value, "value", 0);
|
||||
}
|
||||
|
||||
return new bgfx_suppressor(check_sliders, condition, mode, values);
|
||||
return new bgfx_suppressor(std::move(check_sliders), condition, mode, values);
|
||||
}
|
||||
|
||||
bool suppressor_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool suppressor_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(value["type"].IsString(), (prefix + "Value 'type' must be a string\n").c_str())) return false;
|
||||
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("value"), (prefix + "Must have numeric or array value 'value'\n").c_str())) return false;
|
||||
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;
|
||||
if (!READER_CHECK(value["type"].IsString(), "%sValue 'type' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("name"), "%sMust have string value 'name'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["name"].IsString(), "%sValue 'name' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("value"), "%sMust have numeric or array value 'value'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["value"].IsNumber() || value["value"].IsArray(), "%sValue 'value' must be a number or array the size of the corresponding slider type\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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 Value& value_array = value[name_str];
|
||||
const Value& value_array = value[name.c_str()];
|
||||
for (uint32_t i = 0; i < value_array.Size() && i < count; i++)
|
||||
{
|
||||
if (!READER_CHECK(value_array[i].IsInt(), (prefix + "value[" + std::to_string(i) + "] must be an integer\n").c_str())) return false;
|
||||
if (!READER_CHECK(value_array[i].IsInt(), "%svalue[%u] must be an integer\n", prefix, i)) return false;
|
||||
values[i] = value_array[i].GetInt();
|
||||
}
|
||||
return true;
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_SUPPRESSORREADER_H
|
||||
#define MAME_RENDER_BGFX_SUPPRESSORREADER_H
|
||||
|
||||
#ifndef __DRAWBGFX_SUPPRESSOR_READER__
|
||||
#define __DRAWBGFX_SUPPRESSOR_READER__
|
||||
#pragma once
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
@ -22,11 +22,11 @@ class bgfx_slider;
|
||||
class suppressor_reader : public state_reader
|
||||
{
|
||||
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, const std::string &prefix, std::map<std::string, bgfx_slider*>& sliders);
|
||||
|
||||
private:
|
||||
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 bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
|
||||
static const int CONDITION_COUNT = 2;
|
||||
static const string_to_enum CONDITION_NAMES[CONDITION_COUNT];
|
||||
@ -34,4 +34,4 @@ private:
|
||||
static const string_to_enum COMBINE_NAMES[COMBINE_COUNT];
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_SUPPRESSOR_READER__
|
||||
#endif // MAME_RENDER_BGFX_SUPPRESSORREADER_H
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
#include "targetreader.h"
|
||||
|
||||
#include <modules/lib/osdobj_common.h>
|
||||
|
||||
#include "bgfxutil.h"
|
||||
#include "chainmanager.h"
|
||||
#include "target.h"
|
||||
|
||||
#include "modules/lib/osdobj_common.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
const target_reader::string_to_enum target_reader::STYLE_NAMES[target_reader::STYLE_COUNT] = {
|
||||
@ -22,7 +22,13 @@ const target_reader::string_to_enum target_reader::STYLE_NAMES[target_reader::ST
|
||||
{ "custom", TARGET_STYLE_CUSTOM }
|
||||
};
|
||||
|
||||
bgfx_target* target_reader::read_from_value(const Value& value, std::string prefix, chain_manager& chains, uint32_t screen_index, uint16_t user_prescale, uint16_t max_prescale_size)
|
||||
bgfx_target* target_reader::read_from_value(
|
||||
const Value& value,
|
||||
const std::string &prefix,
|
||||
chain_manager& chains,
|
||||
uint32_t screen_index,
|
||||
uint16_t user_prescale,
|
||||
uint16_t max_prescale_size)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -71,11 +77,11 @@ bgfx_target* target_reader::read_from_value(const Value& value, std::string pref
|
||||
}
|
||||
break;
|
||||
case TARGET_STYLE_CUSTOM:
|
||||
READER_WARN(!value.HasMember("user_prescale"), (prefix + "Target '" + target_name + "': user_prescale parameter is not used for custom-type render targets.\n").c_str());
|
||||
if (!READER_CHECK(value.HasMember("width"), (prefix + "Target '" + target_name + "': Must have numeric value 'width'\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(value["width"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'width' must be a number\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(value.HasMember("height"), (prefix + "Target '" + target_name + "': Must have numeric value 'height'\n").c_str())) return nullptr;
|
||||
if (!READER_CHECK(value["height"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'height' must be a number\n").c_str())) return nullptr;
|
||||
READER_WARN(!value.HasMember("user_prescale"), "%sTarget '%s': user_prescale parameter is not used for custom-type render targets.\n", prefix, target_name);
|
||||
if (!READER_CHECK(value.HasMember("width"), "%sTarget '%s': Must have numeric value 'width'\n", prefix, target_name)) return nullptr;
|
||||
if (!READER_CHECK(value["width"].IsNumber(), "%sTarget '%s': Value 'width' must be a number\n", prefix, target_name)) return nullptr;
|
||||
if (!READER_CHECK(value.HasMember("height"), "%sTarget '%s': Must have numeric value 'height'\n", prefix, target_name)) return nullptr;
|
||||
if (!READER_CHECK(value["height"].IsNumber(), "%sTarget '%s': Value 'height' must be a number\n", prefix, target_name)) return nullptr;
|
||||
width = uint16_t(value["width"].GetDouble());
|
||||
height = uint16_t(value["height"].GetDouble());
|
||||
break;
|
||||
@ -84,15 +90,15 @@ bgfx_target* target_reader::read_from_value(const Value& value, std::string pref
|
||||
return chains.targets().create_target(target_name, bgfx::TextureFormat::BGRA8, width, height, xprescale, yprescale, mode, double_buffer, bilinear, scale, screen_index);
|
||||
}
|
||||
|
||||
bool target_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool target_reader::validate_parameters(const Value& value, const 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("user_prescale") || value["user_prescale"].IsBool(), (prefix + "Value 'user_prescale' must be a boolean\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("scale") || value["scale"].IsNumber(), (prefix + "Value 'scale' must be a numeric value\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("name"), "%sMust have string value 'name'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["name"].IsString(), "%sValue 'name' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("mode"), "%sMust have string enum 'mode'\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["mode"].IsString(), "%sValue 'mode' must be a string (what screens does this apply to?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("bilinear") || value["bilinear"].IsBool(), "%sValue 'bilinear' must be a boolean\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("doublebuffer") || value["doublebuffer"].IsBool(), "%sValue 'doublebuffer' must be a boolean\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("user_prescale") || value["user_prescale"].IsBool(), "%sValue 'user_prescale' must be a boolean\n", prefix)) return false;
|
||||
if (!READER_CHECK(!value.HasMember("scale") || value["scale"].IsNumber(), "%sValue 'scale' must be a numeric value\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,28 +6,28 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_TARGETREADER_H
|
||||
#define MAME_RENDER_BGFX_TARGETREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_TARGET_READER__
|
||||
#define __DRAWBGFX_TARGET_READER__
|
||||
#include "statereader.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
class bgfx_target;
|
||||
class chain_manager;
|
||||
|
||||
class target_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static bgfx_target* read_from_value(const Value& value, std::string prefix, chain_manager& chains, uint32_t screen_index, uint16_t user_prescale, uint16_t max_prescale_size);
|
||||
static bgfx_target* read_from_value(const Value& value, const std::string &prefix, chain_manager& chains, uint32_t screen_index, uint16_t user_prescale, uint16_t max_prescale_size);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
|
||||
static const int STYLE_COUNT = 3;
|
||||
static const string_to_enum STYLE_NAMES[STYLE_COUNT];
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_TARGET_READER__
|
||||
#endif // MAME_RENDER_BGFX_TARGETREADER_H
|
||||
|
@ -69,7 +69,7 @@ bgfx_texture* texture_manager::create_png_texture(std::string path, std::string
|
||||
|
||||
if (bitmap.width() == 0 || bitmap.height() == 0)
|
||||
{
|
||||
osd_printf_error("Unable to load PNG '%s' from path '%s'\n", file_name.c_str(), path.c_str());
|
||||
osd_printf_error("Unable to load PNG '%s' from path '%s'\n", file_name, path);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,10 @@
|
||||
|
||||
#include "timeparameter.h"
|
||||
|
||||
bgfx_time_parameter::bgfx_time_parameter(std::string name, parameter_type type, double limit)
|
||||
: bgfx_parameter(name, type)
|
||||
#include <utility>
|
||||
|
||||
bgfx_time_parameter::bgfx_time_parameter(std::string &&name, parameter_type type, double limit)
|
||||
: bgfx_parameter(std::move(name), type)
|
||||
, m_current_time(0)
|
||||
, m_limit(limit)
|
||||
{
|
||||
|
@ -6,22 +6,19 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_TIMEPARAMETER_H
|
||||
#define MAME_RENDER_BGFX_TIMEPARAMETER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_TIME_PARAMETER__
|
||||
#define __DRAWBGFX_TIME_PARAMETER__
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
#include "parameter.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "parameter.h"
|
||||
|
||||
class bgfx_time_parameter : public bgfx_parameter
|
||||
{
|
||||
public:
|
||||
bgfx_time_parameter(std::string name, parameter_type type, double limit);
|
||||
virtual ~bgfx_time_parameter() { }
|
||||
bgfx_time_parameter(std::string &&name, parameter_type type, double limit);
|
||||
|
||||
virtual float value() override;
|
||||
virtual void tick(double delta) override;
|
||||
@ -31,4 +28,4 @@ private:
|
||||
double m_limit;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_TIME_PARAMETER__
|
||||
#endif // MAME_RENDER_BGFX_TIMEPARAMETER_H
|
||||
|
@ -7,10 +7,12 @@
|
||||
//============================================================
|
||||
|
||||
#include "uniform.h"
|
||||
#include <cstring>
|
||||
|
||||
bgfx_uniform::bgfx_uniform(std::string name, bgfx::UniformType::Enum type)
|
||||
: m_name(name)
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
bgfx_uniform::bgfx_uniform(std::string &&name, bgfx::UniformType::Enum type)
|
||||
: m_name(std::move(name))
|
||||
, m_type(type)
|
||||
{
|
||||
m_handle = BGFX_INVALID_HANDLE;
|
||||
|
@ -6,10 +6,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_UNIFORM_H
|
||||
#define MAME_RENDER_BGFX_UNIFORM_H
|
||||
|
||||
#ifndef __DRAWBGFX_UNIFORM__
|
||||
#define __DRAWBGFX_UNIFORM__
|
||||
#pragma once
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
class bgfx_uniform
|
||||
{
|
||||
public:
|
||||
bgfx_uniform(std::string name, bgfx::UniformType::Enum type);
|
||||
bgfx_uniform(std::string &&name, bgfx::UniformType::Enum type);
|
||||
virtual ~bgfx_uniform();
|
||||
|
||||
virtual void upload();
|
||||
@ -26,7 +26,7 @@ public:
|
||||
void create();
|
||||
|
||||
// Getters
|
||||
std::string name() { return m_name; }
|
||||
const std::string &name() { return m_name; }
|
||||
bgfx::UniformType::Enum type() const { return m_type; }
|
||||
bgfx::UniformHandle handle() const { return m_handle; }
|
||||
|
||||
@ -47,4 +47,4 @@ protected:
|
||||
size_t m_data_size;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_UNIFORM__
|
||||
#endif // MAME_RENDER_BGFX_UNIFORM_H
|
||||
|
@ -17,7 +17,7 @@ const uniform_reader::string_to_enum uniform_reader::TYPE_NAMES[uniform_reader::
|
||||
{ "mat4", bgfx::UniformType::Mat4 }
|
||||
};
|
||||
|
||||
bgfx_uniform* uniform_reader::read_from_value(const Value& value, std::string prefix)
|
||||
bgfx_uniform* uniform_reader::read_from_value(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -52,12 +52,12 @@ bgfx_uniform* uniform_reader::read_from_value(const Value& value, std::string pr
|
||||
return uniform;
|
||||
}
|
||||
|
||||
bool uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool uniform_reader::validate_parameters(const Value& value, const 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;
|
||||
if (!READER_CHECK(value.HasMember("name"), "%sMust have string value 'name' (what is this uniform called in the shader code?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["name"].IsString(), "%sValue 'name' must be a string\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("type"), "%sMust have string value 'type' [int, vec4, mat3, mat4]\n", prefix)) return false;
|
||||
if (!READER_CHECK(value.HasMember("values"), "%sMust have array value 'values' (what are the uniform's default values?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["values"].IsArray(), "%sValue 'values' must be an array\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,13 +6,11 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_UNIFORMREADER_H
|
||||
#define MAME_RENDER_BGFX_UNIFORMREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_UNIFORM_READER__
|
||||
#define __DRAWBGFX_UNIFORM_READER__
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
class bgfx_uniform;
|
||||
@ -20,13 +18,13 @@ class bgfx_uniform;
|
||||
class uniform_reader : public state_reader
|
||||
{
|
||||
public:
|
||||
static bgfx_uniform* read_from_value(const Value& value, std::string prefix);
|
||||
static bgfx_uniform* read_from_value(const Value& value, const std::string &prefix);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
|
||||
static const int TYPE_COUNT = 4;
|
||||
static const string_to_enum TYPE_NAMES[TYPE_COUNT];
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_UNIFORM_READER__
|
||||
#endif // MAME_RENDER_BGFX_UNIFORMREADER_H
|
||||
|
@ -10,7 +10,7 @@
|
||||
//============================================================
|
||||
|
||||
#include "valueuniform.h"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
bgfx_value_uniform::bgfx_value_uniform(bgfx_uniform* uniform, float* values, const int count)
|
||||
: bgfx_entry_uniform(uniform)
|
||||
|
@ -9,10 +9,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_RENDER_BGFX_VALUEUNIFORM_H
|
||||
#define MAME_RENDER_BGFX_VALUEUNIFORM_H
|
||||
|
||||
#ifndef __DRAWBGFX_VALUE_UNIFORM__
|
||||
#define __DRAWBGFX_VALUE_UNIFORM__
|
||||
#pragma once
|
||||
|
||||
#include "entryuniform.h"
|
||||
|
||||
@ -28,4 +28,4 @@ private:
|
||||
const int m_count;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_VALUE_UNIFORM__
|
||||
#endif // MAME_RENDER_BGFX_VALUEUNIFORM_H
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "entryuniform.h"
|
||||
#include "valueuniform.h"
|
||||
|
||||
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, const std::string &prefix, bgfx_uniform* uniform)
|
||||
{
|
||||
if (!validate_parameters(value, prefix))
|
||||
{
|
||||
@ -36,9 +36,9 @@ bgfx_entry_uniform* value_uniform_reader::read_from_value(const Value& value, st
|
||||
return new bgfx_value_uniform(uniform, values, count);
|
||||
}
|
||||
|
||||
bool value_uniform_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
bool value_uniform_reader::validate_parameters(const Value& value, const std::string &prefix)
|
||||
{
|
||||
if (!READER_CHECK(value.HasMember("value"), (prefix + "Must have string value 'value' (what value is being assigned?)\n").c_str())) return false;
|
||||
if (!READER_CHECK(value["value"].IsArray() || value["value"].IsNumber(), (prefix + "Value 'value' must be numeric or an array\n").c_str())) return false;
|
||||
if (!READER_CHECK(value.HasMember("value"), "%sMust have string value 'value' (what value is being assigned?)\n", prefix)) return false;
|
||||
if (!READER_CHECK(value["value"].IsArray() || value["value"].IsNumber(), "%sValue 'value' must be numeric or an array\n", prefix)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -6,15 +6,14 @@
|
||||
//
|
||||
//================================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_VALUEUNIFORMREADER_H
|
||||
#define MAME_RENDER_BGFX_VALUEUNIFORMREADER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_VALUE_UNIFORM_READER__
|
||||
#define __DRAWBGFX_VALUE_UNIFORM_READER__
|
||||
#include "statereader.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
class bgfx_entry_uniform;
|
||||
class bgfx_uniform;
|
||||
@ -22,10 +21,10 @@ class bgfx_uniform;
|
||||
class value_uniform_reader : public state_reader
|
||||
{
|
||||
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, const std::string &prefix, bgfx_uniform* uniform);
|
||||
|
||||
private:
|
||||
static bool validate_parameters(const Value& value, std::string prefix);
|
||||
static bool validate_parameters(const Value& value, const std::string &prefix);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_VALUE_UNIFORM_READER__
|
||||
#endif // MAME_RENDER_BGFX_VALUEUNIFORMREADER_H
|
||||
|
@ -6,22 +6,20 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef MAME_RENDER_BGFX_WINDOWPARAMETER_H
|
||||
#define MAME_RENDER_BGFX_WINDOWPARAMETER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_WINDOW_PARAMETER__
|
||||
#define __DRAWBGFX_WINDOW_PARAMETER__
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
#include "parameter.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "parameter.h"
|
||||
#include <utility>
|
||||
|
||||
class bgfx_window_parameter : public bgfx_parameter
|
||||
{
|
||||
public:
|
||||
bgfx_window_parameter(std::string name, parameter_type type, uint32_t index) : bgfx_parameter(name, type), m_index(index) { }
|
||||
virtual ~bgfx_window_parameter() { }
|
||||
bgfx_window_parameter(std::string &&name, parameter_type type, uint32_t index) : bgfx_parameter(std::move(name), type), m_index(index) { }
|
||||
|
||||
virtual float value() override { return float(m_index); }
|
||||
virtual void tick(double delta) override { }
|
||||
@ -30,4 +28,4 @@ private:
|
||||
uint32_t m_index;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_WINDOW_PARAMETER__
|
||||
#endif // MAME_RENDER_BGFX_WINDOWPARAMETER_H
|
||||
|
Loading…
Reference in New Issue
Block a user