mirror of
https://github.com/libretro/mame.git
synced 2024-11-23 09:29:54 +00: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
|
||||
|
@ -39,26 +39,26 @@ uniform vec4 SB_THRESHOLD;
|
||||
|
||||
bool eq(vec3 c1, vec3 c2)
|
||||
{
|
||||
vec3 df = abs(c1 - c2);
|
||||
return df.r < SB_THRESHOLD.r && df.g < SB_THRESHOLD.g && df.b < SB_THRESHOLD.b;
|
||||
vec3 df = abs(c1 - c2);
|
||||
return df.r < SB_THRESHOLD.r && df.g < SB_THRESHOLD.g && df.b < SB_THRESHOLD.b;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 A = texture2D(s_p, v_texcoord1.xw).xyz;
|
||||
vec3 B = texture2D(s_p, v_texcoord1.yw).xyz;
|
||||
vec3 C = texture2D(s_p, v_texcoord1.zw).xyz;
|
||||
vec3 D = texture2D(s_p, v_texcoord2.xw).xyz;
|
||||
vec3 E = texture2D(s_p, v_texcoord2.yw).xyz;
|
||||
vec3 F = texture2D(s_p, v_texcoord2.zw).xyz;
|
||||
vec3 G = texture2D(s_p, v_texcoord3.xw).xyz;
|
||||
vec3 H = texture2D(s_p, v_texcoord3.yw).xyz;
|
||||
vec3 I = texture2D(s_p, v_texcoord3.zw).xyz;
|
||||
vec3 A = texture2D(s_p, v_texcoord1.xw).xyz;
|
||||
vec3 B = texture2D(s_p, v_texcoord1.yw).xyz;
|
||||
vec3 C = texture2D(s_p, v_texcoord1.zw).xyz;
|
||||
vec3 D = texture2D(s_p, v_texcoord2.xw).xyz;
|
||||
vec3 E = texture2D(s_p, v_texcoord2.yw).xyz;
|
||||
vec3 F = texture2D(s_p, v_texcoord2.zw).xyz;
|
||||
vec3 G = texture2D(s_p, v_texcoord3.xw).xyz;
|
||||
vec3 H = texture2D(s_p, v_texcoord3.yw).xyz;
|
||||
vec3 I = texture2D(s_p, v_texcoord3.zw).xyz;
|
||||
|
||||
if (eq(E,F) && eq(E,H) && eq(E,I) && eq(E,B) && eq(E,C) && eq(E,A) && eq(E,D) && eq(E,G))
|
||||
{
|
||||
E = (A + B + C + D + E + F + G + H + I) / 9.0;
|
||||
}
|
||||
if (eq(E,F) && eq(E,H) && eq(E,I) && eq(E,B) && eq(E,C) && eq(E,A) && eq(E,D) && eq(E,G))
|
||||
{
|
||||
E = (A + B + C + D + E + F + G + H + I) / 9.0;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(E, 1.0);
|
||||
gl_FragColor = vec4(E, 1.0);
|
||||
}
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
vec4 TEX2D(vec2 c)
|
||||
{
|
||||
vec2 underscan = step(0.0,c) * step(0.0,vec2_splat(1.0)-c);
|
||||
vec4 col = texture2D(mpass_texture, c) * vec4_splat(underscan.x*underscan.y);
|
||||
vec2 underscan = step(0.0,c) * step(0.0,vec2_splat(1.0)-c);
|
||||
vec4 col = texture2D(mpass_texture, c) * vec4_splat(underscan.x*underscan.y);
|
||||
#ifdef LINEAR_PROCESSING
|
||||
col = pow(col, vec4_splat(CRTgamma.x));
|
||||
col = pow(col, vec4_splat(CRTgamma.x));
|
||||
#endif
|
||||
return col;
|
||||
return col;
|
||||
}
|
||||
|
||||
// Enable screen curvature.
|
||||
@ -48,43 +48,43 @@ uniform vec4 cornersmooth;
|
||||
|
||||
float intersect(vec2 xy , vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
float A = dot(xy,xy)+d.x*d.x;
|
||||
float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x);
|
||||
float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y;
|
||||
return (-B-sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
float A = dot(xy,xy)+d.x*d.x;
|
||||
float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x);
|
||||
float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y;
|
||||
return (-B-sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
}
|
||||
|
||||
vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
float c = intersect(xy, sinangle, cosangle);
|
||||
vec2 pt = vec2_splat(c)*xy;
|
||||
pt -= vec2_splat(-R.x)*sinangle;
|
||||
pt /= vec2_splat(R.x);
|
||||
vec2 tang = sinangle/cosangle;
|
||||
vec2 poc = pt/cosangle;
|
||||
float A = dot(tang,tang)+1.0;
|
||||
float B = -2.0*dot(poc,tang);
|
||||
float C = dot(poc,poc)-1.0;
|
||||
float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
vec2 uv = (pt-a*sinangle)/cosangle;
|
||||
float r = FIX(R.x*acos(a));
|
||||
return uv*r/sin(r/R.x);
|
||||
float c = intersect(xy, sinangle, cosangle);
|
||||
vec2 pt = vec2_splat(c)*xy;
|
||||
pt -= vec2_splat(-R.x)*sinangle;
|
||||
pt /= vec2_splat(R.x);
|
||||
vec2 tang = sinangle/cosangle;
|
||||
vec2 poc = pt/cosangle;
|
||||
float A = dot(tang,tang)+1.0;
|
||||
float B = -2.0*dot(poc,tang);
|
||||
float C = dot(poc,poc)-1.0;
|
||||
float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
vec2 uv = (pt-a*sinangle)/cosangle;
|
||||
float r = FIX(R.x*acos(a));
|
||||
return uv*r/sin(r/R.x);
|
||||
}
|
||||
|
||||
vec2 transform(vec2 coord, vec3 stretch, vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
coord = (coord-vec2_splat(0.5))*aspect.xy*stretch.z+stretch.xy;
|
||||
return (bkwtrans(coord, sinangle, cosangle)/overscan.xy/aspect.xy+vec2_splat(0.5));
|
||||
coord = (coord-vec2_splat(0.5))*aspect.xy*stretch.z+stretch.xy;
|
||||
return (bkwtrans(coord, sinangle, cosangle)/overscan.xy/aspect.xy+vec2_splat(0.5));
|
||||
}
|
||||
|
||||
float corner(vec2 coord)
|
||||
{
|
||||
coord = (coord - vec2_splat(0.5)) * overscan.xy + vec2_splat(0.5);
|
||||
coord = min(coord, vec2_splat(1.0)-coord) * aspect.xy;
|
||||
vec2 cdist = vec2_splat(cornersize.x);
|
||||
coord = (cdist - min(coord,cdist));
|
||||
float dist = sqrt(dot(coord,coord));
|
||||
return clamp((max(cdist.x,1e-3)-dist)*cornersmooth.x,0.0, 1.0);
|
||||
coord = (coord - vec2_splat(0.5)) * overscan.xy + vec2_splat(0.5);
|
||||
coord = min(coord, vec2_splat(1.0)-coord) * aspect.xy;
|
||||
vec2 cdist = vec2_splat(cornersize.x);
|
||||
coord = (cdist - min(coord,cdist));
|
||||
float dist = sqrt(dot(coord,coord));
|
||||
return clamp((max(cdist.x,1e-3)-dist)*cornersmooth.x,0.0, 1.0);
|
||||
}
|
||||
|
||||
// Calculate the influence of a scanline on the current pixel.
|
||||
@ -95,109 +95,109 @@ float corner(vec2 coord)
|
||||
// the current pixel.
|
||||
vec4 scanlineWeights(float distance, vec4 color)
|
||||
{
|
||||
// "wid" controls the width of the scanline beam, for each RGB channel
|
||||
// The "weights" lines basically specify the formula that gives
|
||||
// you the profile of the beam, i.e. the intensity as
|
||||
// a function of distance from the vertical center of the
|
||||
// scanline. In this case, it is gaussian if width=2, and
|
||||
// becomes nongaussian for larger widths. Ideally this should
|
||||
// be normalized so that the integral across the beam is
|
||||
// independent of its width. That is, for a narrower beam
|
||||
// "weights" should have a higher peak at the center of the
|
||||
// scanline than for a wider beam.
|
||||
// "wid" controls the width of the scanline beam, for each RGB channel
|
||||
// The "weights" lines basically specify the formula that gives
|
||||
// you the profile of the beam, i.e. the intensity as
|
||||
// a function of distance from the vertical center of the
|
||||
// scanline. In this case, it is gaussian if width=2, and
|
||||
// becomes nongaussian for larger widths. Ideally this should
|
||||
// be normalized so that the integral across the beam is
|
||||
// independent of its width. That is, for a narrower beam
|
||||
// "weights" should have a higher peak at the center of the
|
||||
// scanline than for a wider beam.
|
||||
#ifdef USEGAUSSIAN
|
||||
vec4 wid = spot_size.x + spot_growth.x * pow(color, vec4_splat(spot_growth_power.x));
|
||||
vec4 weights = vec4(distance / wid);
|
||||
float maxwid = spot_size.x + spot_growth.x;
|
||||
float norm = maxwid / ( 1.0 + exp(-1.0/(maxwid*maxwid)) );
|
||||
return norm * exp(-weights * weights) / wid;
|
||||
vec4 wid = spot_size.x + spot_growth.x * pow(color, vec4_splat(spot_growth_power.x));
|
||||
vec4 weights = vec4(distance / wid);
|
||||
float maxwid = spot_size.x + spot_growth.x;
|
||||
float norm = maxwid / ( 1.0 + exp(-1.0/(maxwid*maxwid)) );
|
||||
return norm * exp(-weights * weights) / wid;
|
||||
#else
|
||||
vec4 wid = 2.0 + 2.0 * pow(color, vec4_splat(4.0));
|
||||
vec4 weights = vec4_splat(distance / 0.3);
|
||||
return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
|
||||
vec4 wid = 2.0 + 2.0 * pow(color, vec4_splat(4.0));
|
||||
vec4 weights = vec4_splat(distance / 0.3);
|
||||
return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
|
||||
#endif
|
||||
}
|
||||
|
||||
vec4 cubic(vec4 x, float B, float C)
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/Mitchell%E2%80%93Netravali_filters
|
||||
vec2 a = x.yz; // components in [0,1]
|
||||
vec2 b = x.xw; // components in [1,2]
|
||||
vec2 a2 = a*a;
|
||||
vec2 b2 = b*b;
|
||||
a = (2.0-1.5*B-1.0*C)*a*a2 + (-3.0+2.0*B+C)*a2 + (1.0-(1.0/3.0)*B);
|
||||
b = ((-1.0/6.0)*B-C)*b*b2 + (B+5.0*C)*b2 + (-2.0*B-8.0*C)*b + ((4.0/3.0)*B+4.0*C);
|
||||
return vec4(b.x,a.x,a.y,b.y);
|
||||
// https://en.wikipedia.org/wiki/Mitchell%E2%80%93Netravali_filters
|
||||
vec2 a = x.yz; // components in [0,1]
|
||||
vec2 b = x.xw; // components in [1,2]
|
||||
vec2 a2 = a*a;
|
||||
vec2 b2 = b*b;
|
||||
a = (2.0-1.5*B-1.0*C)*a*a2 + (-3.0+2.0*B+C)*a2 + (1.0-(1.0/3.0)*B);
|
||||
b = ((-1.0/6.0)*B-C)*b*b2 + (B+5.0*C)*b2 + (-2.0*B-8.0*C)*b + ((4.0/3.0)*B+4.0*C);
|
||||
return vec4(b.x,a.x,a.y,b.y);
|
||||
}
|
||||
|
||||
vec4 x_coeffs(vec4 x, float pos_x)
|
||||
{
|
||||
if (u_interp.x < 0.5) { // box
|
||||
float wid = length(vec2(dFdx(pos_x),dFdy(pos_x)));
|
||||
float dx = clamp((0.5 + 0.5*wid - x.y)/wid, 0.0, 1.0);
|
||||
return vec4(0.0,dx,1.0-dx,0.0);
|
||||
} else if (u_interp.x < 1.5) { // linear
|
||||
return vec4(0.0, 1.0-x.y, 1.0-x.z, 0.0);
|
||||
} else if (u_interp.x < 2.5) { // Lanczos
|
||||
// Prevent division by zero.
|
||||
vec4 coeffs = FIX(PI * x);
|
||||
// Lanczos2 kernel.
|
||||
coeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs);
|
||||
// Normalize.
|
||||
coeffs /= dot(coeffs, vec4_splat(1.0));
|
||||
return coeffs;
|
||||
} else if (u_interp.x < 3.5) { // Catmull-Rom
|
||||
return cubic(x,0.0,0.5);
|
||||
} else if (u_interp.x < 4.5) { // Mitchell-Netravali
|
||||
return cubic(x,1.0/3.0,1.0/3.0);
|
||||
} else /*if (u_interp.x < 5.5)*/ { // B-spline
|
||||
return cubic(x,1.0,0.0);
|
||||
}
|
||||
if (u_interp.x < 0.5) { // box
|
||||
float wid = length(vec2(dFdx(pos_x),dFdy(pos_x)));
|
||||
float dx = clamp((0.5 + 0.5*wid - x.y)/wid, 0.0, 1.0);
|
||||
return vec4(0.0,dx,1.0-dx,0.0);
|
||||
} else if (u_interp.x < 1.5) { // linear
|
||||
return vec4(0.0, 1.0-x.y, 1.0-x.z, 0.0);
|
||||
} else if (u_interp.x < 2.5) { // Lanczos
|
||||
// Prevent division by zero.
|
||||
vec4 coeffs = FIX(PI * x);
|
||||
// Lanczos2 kernel.
|
||||
coeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs);
|
||||
// Normalize.
|
||||
coeffs /= dot(coeffs, vec4_splat(1.0));
|
||||
return coeffs;
|
||||
} else if (u_interp.x < 3.5) { // Catmull-Rom
|
||||
return cubic(x,0.0,0.5);
|
||||
} else if (u_interp.x < 4.5) { // Mitchell-Netravali
|
||||
return cubic(x,1.0/3.0,1.0/3.0);
|
||||
} else /*if (u_interp.x < 5.5)*/ { // B-spline
|
||||
return cubic(x,1.0,0.0);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 sample_scanline(vec2 xy, vec4 coeffs, float onex)
|
||||
{
|
||||
// Calculate the effective colour of the given
|
||||
// scanline at the horizontal location of the current pixel,
|
||||
// using the Lanczos coefficients.
|
||||
vec4 col = clamp(TEX2D(xy + vec2(-onex, 0.0))*coeffs.x +
|
||||
TEX2D(xy)*coeffs.y +
|
||||
TEX2D(xy +vec2(onex, 0.0))*coeffs.z +
|
||||
TEX2D(xy + vec2(2.0 * onex, 0.0))*coeffs.w , 0.0, 1.0);
|
||||
return col;
|
||||
// Calculate the effective colour of the given
|
||||
// scanline at the horizontal location of the current pixel,
|
||||
// using the Lanczos coefficients.
|
||||
vec4 col = clamp(TEX2D(xy + vec2(-onex, 0.0))*coeffs.x +
|
||||
TEX2D(xy)*coeffs.y +
|
||||
TEX2D(xy +vec2(onex, 0.0))*coeffs.z +
|
||||
TEX2D(xy + vec2(2.0 * onex, 0.0))*coeffs.w , 0.0, 1.0);
|
||||
return col;
|
||||
}
|
||||
|
||||
vec3 apply_shadow_mask(vec2 coord, vec3 col)
|
||||
{
|
||||
vec2 xy = coord * u_quad_dims.xy / u_tex_size1.xy;
|
||||
vec4 mask = texture2D(mask_texture, xy);
|
||||
// count of total bright pixels is encoded in the mask's alpha channel
|
||||
float nbright = 255.0 - 255.0*mask.a;
|
||||
// fraction of bright pixels in the mask
|
||||
float fbright = nbright / ( u_tex_size1.x * u_tex_size1.y );
|
||||
// average darkening factor of the mask
|
||||
float aperture_average = mix(1.0-aperture_strength.x*(1.0-aperture_brightboost.x), 1.0, fbright);
|
||||
// colour of dark mask pixels
|
||||
vec3 clow = vec3_splat(1.0-aperture_strength.x) * col + vec3_splat(aperture_strength.x*(aperture_brightboost.x)) * col * col;
|
||||
float ifbright = 1.0 / fbright;
|
||||
// colour of bright mask pixels
|
||||
vec3 chi = vec3_splat(ifbright*aperture_average) * col - vec3_splat(ifbright - 1.0) * clow;
|
||||
return mix(clow,chi,mask.rgb); // mask texture selects dark vs bright
|
||||
vec2 xy = coord * u_quad_dims.xy / u_tex_size1.xy;
|
||||
vec4 mask = texture2D(mask_texture, xy);
|
||||
// count of total bright pixels is encoded in the mask's alpha channel
|
||||
float nbright = 255.0 - 255.0*mask.a;
|
||||
// fraction of bright pixels in the mask
|
||||
float fbright = nbright / ( u_tex_size1.x * u_tex_size1.y );
|
||||
// average darkening factor of the mask
|
||||
float aperture_average = mix(1.0-aperture_strength.x*(1.0-aperture_brightboost.x), 1.0, fbright);
|
||||
// colour of dark mask pixels
|
||||
vec3 clow = vec3_splat(1.0-aperture_strength.x) * col + vec3_splat(aperture_strength.x*(aperture_brightboost.x)) * col * col;
|
||||
float ifbright = 1.0 / fbright;
|
||||
// colour of bright mask pixels
|
||||
vec3 chi = vec3_splat(ifbright*aperture_average) * col - vec3_splat(ifbright - 1.0) * clow;
|
||||
return mix(clow,chi,mask.rgb); // mask texture selects dark vs bright
|
||||
}
|
||||
|
||||
vec3 linear_to_sRGB(vec3 col)
|
||||
{
|
||||
// only applies the gamma ramp; does not adjust the primaries
|
||||
vec3 linear_ramp = vec3(lessThan(col, vec3_splat(0.0031308)));
|
||||
vec3 clin = col * vec3_splat(12.92);
|
||||
vec3 cpow = pow(col, vec3_splat(1.0/2.4)) * vec3_splat(1.055) - vec3_splat(0.055);
|
||||
return mix(cpow, clin, linear_ramp);
|
||||
// only applies the gamma ramp; does not adjust the primaries
|
||||
vec3 linear_ramp = vec3(lessThan(col, vec3_splat(0.0031308)));
|
||||
vec3 clin = col * vec3_splat(12.92);
|
||||
vec3 cpow = pow(col, vec3_splat(1.0/2.4)) * vec3_splat(1.055) - vec3_splat(0.055);
|
||||
return mix(cpow, clin, linear_ramp);
|
||||
}
|
||||
|
||||
vec3 linear_to_output(vec3 col)
|
||||
{
|
||||
if (monitorsRGB.x > 0.5)
|
||||
return linear_to_sRGB(col);
|
||||
else
|
||||
return pow(col, vec3_splat(1.0 / monitorgamma.x));
|
||||
if (monitorsRGB.x > 0.5)
|
||||
return linear_to_sRGB(col);
|
||||
else
|
||||
return pow(col, vec3_splat(1.0 / monitorgamma.x));
|
||||
}
|
||||
|
@ -24,79 +24,79 @@ uniform vec4 u_quad_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Here's a helpful diagram to keep in mind while trying to
|
||||
// understand the code:
|
||||
//
|
||||
// | | | | |
|
||||
// -------------------------------
|
||||
// | | | | |
|
||||
// | 01 | 11 | 21 | 31 | <-- current scanline
|
||||
// | | @ | | |
|
||||
// -------------------------------
|
||||
// | | | | |
|
||||
// | 02 | 12 | 22 | 32 | <-- next scanline
|
||||
// | | | | |
|
||||
// -------------------------------
|
||||
// | | | | |
|
||||
//
|
||||
// Each character-cell represents a pixel on the output
|
||||
// surface, "@" represents the current pixel (always somewhere
|
||||
// in the bottom half of the current scan-line, or the top-half
|
||||
// of the next scanline). The grid of lines represents the
|
||||
// edges of the texels of the underlying texture.
|
||||
// Here's a helpful diagram to keep in mind while trying to
|
||||
// understand the code:
|
||||
//
|
||||
// | | | | |
|
||||
// -------------------------------
|
||||
// | | | | |
|
||||
// | 01 | 11 | 21 | 31 | <-- current scanline
|
||||
// | | @ | | |
|
||||
// -------------------------------
|
||||
// | | | | |
|
||||
// | 02 | 12 | 22 | 32 | <-- next scanline
|
||||
// | | | | |
|
||||
// -------------------------------
|
||||
// | | | | |
|
||||
//
|
||||
// Each character-cell represents a pixel on the output
|
||||
// surface, "@" represents the current pixel (always somewhere
|
||||
// in the bottom half of the current scan-line, or the top-half
|
||||
// of the next scanline). The grid of lines represents the
|
||||
// edges of the texels of the underlying texture.
|
||||
|
||||
// Texture coordinates of the texel containing the active pixel.
|
||||
vec2 xy;
|
||||
if (curvature.x > 0.5)
|
||||
xy = transform(v_texCoord, v_stretch, v_sinangle, v_cosangle);
|
||||
else
|
||||
xy = (v_texCoord-vec2_splat(0.5))/overscan.xy+vec2_splat(0.5);
|
||||
float cval = corner(xy);
|
||||
// Texture coordinates of the texel containing the active pixel.
|
||||
vec2 xy;
|
||||
if (curvature.x > 0.5)
|
||||
xy = transform(v_texCoord, v_stretch, v_sinangle, v_cosangle);
|
||||
else
|
||||
xy = (v_texCoord-vec2_splat(0.5))/overscan.xy+vec2_splat(0.5);
|
||||
float cval = corner(xy);
|
||||
|
||||
// Of all the pixels that are mapped onto the texel we are
|
||||
// currently rendering, which pixel are we currently rendering?
|
||||
vec2 ratio_scale = xy * u_tex_size0.xy - vec2_splat(0.5);
|
||||
// Of all the pixels that are mapped onto the texel we are
|
||||
// currently rendering, which pixel are we currently rendering?
|
||||
vec2 ratio_scale = xy * u_tex_size0.xy - vec2_splat(0.5);
|
||||
|
||||
#ifdef OVERSAMPLE
|
||||
float filter = fwidth(ratio_scale.y);
|
||||
float filter = fwidth(ratio_scale.y);
|
||||
#endif
|
||||
vec2 uv_ratio = fract(ratio_scale);
|
||||
vec2 uv_ratio = fract(ratio_scale);
|
||||
|
||||
// Snap to the center of the underlying texel.
|
||||
xy = (floor(ratio_scale) + vec2_splat(0.5)) / u_tex_size0.xy;
|
||||
// Snap to the center of the underlying texel.
|
||||
xy = (floor(ratio_scale) + vec2_splat(0.5)) / u_tex_size0.xy;
|
||||
|
||||
// Calculate scaling coefficients describing the effect
|
||||
// of various neighbour texels in a scanline on the current
|
||||
// pixel.
|
||||
vec4 coeffs = x_coeffs(vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x), ratio_scale.x);
|
||||
// Calculate scaling coefficients describing the effect
|
||||
// of various neighbour texels in a scanline on the current
|
||||
// pixel.
|
||||
vec4 coeffs = x_coeffs(vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x), ratio_scale.x);
|
||||
|
||||
vec4 col = sample_scanline(xy, coeffs, v_one.x);
|
||||
vec4 col2 = sample_scanline(xy + vec2(0.0, v_one.y), coeffs, v_one.x);
|
||||
vec4 col = sample_scanline(xy, coeffs, v_one.x);
|
||||
vec4 col2 = sample_scanline(xy + vec2(0.0, v_one.y), coeffs, v_one.x);
|
||||
|
||||
#ifndef LINEAR_PROCESSING
|
||||
col = pow(col , vec4_splat(CRTgamma.x));
|
||||
col2 = pow(col2, vec4_splat(CRTgamma.x));
|
||||
col = pow(col , vec4_splat(CRTgamma.x));
|
||||
col2 = pow(col2, vec4_splat(CRTgamma.x));
|
||||
#endif
|
||||
|
||||
// Calculate the influence of the current and next scanlines on
|
||||
// the current pixel.
|
||||
vec4 weights = scanlineWeights(uv_ratio.y, col);
|
||||
vec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2);
|
||||
// Calculate the influence of the current and next scanlines on
|
||||
// the current pixel.
|
||||
vec4 weights = scanlineWeights(uv_ratio.y, col);
|
||||
vec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2);
|
||||
#ifdef OVERSAMPLE
|
||||
uv_ratio.y =uv_ratio.y+1.0/3.0*filter;
|
||||
weights = (weights+scanlineWeights(uv_ratio.y, col))/3.0;
|
||||
weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0;
|
||||
uv_ratio.y =uv_ratio.y-2.0/3.0*filter;
|
||||
weights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0;
|
||||
weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0;
|
||||
uv_ratio.y =uv_ratio.y+1.0/3.0*filter;
|
||||
weights = (weights+scanlineWeights(uv_ratio.y, col))/3.0;
|
||||
weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0;
|
||||
uv_ratio.y =uv_ratio.y-2.0/3.0*filter;
|
||||
weights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0;
|
||||
weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0;
|
||||
#endif
|
||||
vec4 mul_res = col * weights + col2 * weights2 * vec4_splat(cval);
|
||||
vec4 mul_res = col * weights + col2 * weights2 * vec4_splat(cval);
|
||||
|
||||
// Shadow mask
|
||||
vec3 cout = apply_shadow_mask(v_texCoord.xy, mul_res.rgb);
|
||||
// Shadow mask
|
||||
vec3 cout = apply_shadow_mask(v_texCoord.xy, mul_res.rgb);
|
||||
|
||||
// Convert the image gamma for display on our output device.
|
||||
cout = linear_to_output(cout);
|
||||
// Convert the image gamma for display on our output device.
|
||||
cout = linear_to_output(cout);
|
||||
|
||||
gl_FragColor = vec4(cout,mul_res.a);
|
||||
gl_FragColor = vec4(cout,mul_res.a);
|
||||
}
|
||||
|
@ -26,75 +26,75 @@ uniform vec4 u_rotation_type;
|
||||
|
||||
float intersect(vec2 xy , vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
float A = dot(xy,xy)+d.x*d.x;
|
||||
float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x);
|
||||
float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y;
|
||||
return (-B-sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
float A = dot(xy,xy)+d.x*d.x;
|
||||
float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x);
|
||||
float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y;
|
||||
return (-B-sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
}
|
||||
|
||||
vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
float c = intersect(xy, sinangle, cosangle);
|
||||
vec2 pt = vec2_splat(c)*xy;
|
||||
pt -= vec2_splat(-R.x)*sinangle;
|
||||
pt /= vec2_splat(R.x);
|
||||
vec2 tang = sinangle/cosangle;
|
||||
vec2 poc = pt/cosangle;
|
||||
float A = dot(tang,tang)+1.0;
|
||||
float B = -2.0*dot(poc,tang);
|
||||
float C = dot(poc,poc)-1.0;
|
||||
float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
vec2 uv = (pt-a*sinangle)/cosangle;
|
||||
float r = FIX(R.x*acos(a));
|
||||
return uv*r/sin(r/R.x);
|
||||
float c = intersect(xy, sinangle, cosangle);
|
||||
vec2 pt = vec2_splat(c)*xy;
|
||||
pt -= vec2_splat(-R.x)*sinangle;
|
||||
pt /= vec2_splat(R.x);
|
||||
vec2 tang = sinangle/cosangle;
|
||||
vec2 poc = pt/cosangle;
|
||||
float A = dot(tang,tang)+1.0;
|
||||
float B = -2.0*dot(poc,tang);
|
||||
float C = dot(poc,poc)-1.0;
|
||||
float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);
|
||||
vec2 uv = (pt-a*sinangle)/cosangle;
|
||||
float r = FIX(R.x*acos(a));
|
||||
return uv*r/sin(r/R.x);
|
||||
}
|
||||
|
||||
vec2 fwtrans(vec2 uv, vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
float r = FIX(sqrt(dot(uv,uv)));
|
||||
uv *= sin(r/R.x)/r;
|
||||
float x = 1.0-cos(r/R.x);
|
||||
float D = d.x/R.x + x*cosangle.x*cosangle.y+dot(uv,sinangle);
|
||||
return d.x*(uv*cosangle-x*sinangle)/D;
|
||||
float r = FIX(sqrt(dot(uv,uv)));
|
||||
uv *= sin(r/R.x)/r;
|
||||
float x = 1.0-cos(r/R.x);
|
||||
float D = d.x/R.x + x*cosangle.x*cosangle.y+dot(uv,sinangle);
|
||||
return d.x*(uv*cosangle-x*sinangle)/D;
|
||||
}
|
||||
|
||||
vec3 maxscale(vec2 sinangle, vec2 cosangle)
|
||||
{
|
||||
vec2 c = bkwtrans(-R.x * sinangle / (1.0 + R.x/d.x*cosangle.x*cosangle.y), sinangle, cosangle);
|
||||
vec2 a = vec2(0.5,0.5)*aspect.xy;
|
||||
vec2 lo = vec2(fwtrans(vec2(-a.x,c.y), sinangle, cosangle).x,
|
||||
fwtrans(vec2(c.x,-a.y), sinangle, cosangle).y)/aspect.xy;
|
||||
vec2 hi = vec2(fwtrans(vec2(+a.x,c.y), sinangle, cosangle).x,
|
||||
fwtrans(vec2(c.x,+a.y), sinangle, cosangle).y)/aspect.xy;
|
||||
return vec3((hi+lo)*aspect.xy*0.5,max(hi.x-lo.x,hi.y-lo.y));
|
||||
vec2 c = bkwtrans(-R.x * sinangle / (1.0 + R.x/d.x*cosangle.x*cosangle.y), sinangle, cosangle);
|
||||
vec2 a = vec2(0.5,0.5)*aspect.xy;
|
||||
vec2 lo = vec2(fwtrans(vec2(-a.x,c.y), sinangle, cosangle).x,
|
||||
fwtrans(vec2(c.x,-a.y), sinangle, cosangle).y)/aspect.xy;
|
||||
vec2 hi = vec2(fwtrans(vec2(+a.x,c.y), sinangle, cosangle).x,
|
||||
fwtrans(vec2(c.x,+a.y), sinangle, cosangle).y)/aspect.xy;
|
||||
return vec3((hi+lo)*aspect.xy*0.5,max(hi.x-lo.x,hi.y-lo.y));
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
v_texCoord = a_texcoord0;
|
||||
v_texCoord = a_texcoord0;
|
||||
|
||||
// Precalculate a bunch of useful values we'll need in the fragment
|
||||
// shader.
|
||||
vec2 ang;
|
||||
// if (u_rotation_type.x < 0.5)
|
||||
// ang = vec2(0.0,angle.x);
|
||||
// else if (u_rotation_type.x < 1.5)
|
||||
// ang = vec2(angle.x,0.0);
|
||||
// else if (u_rotation_type.x < 2.5)
|
||||
// ang = vec2(0.0,-angle.x);
|
||||
// else
|
||||
// ang = vec2(-angle.x,0.0);
|
||||
ang = angle.xy;
|
||||
v_sinangle = sin(ang);
|
||||
v_cosangle = cos(ang);
|
||||
v_stretch = maxscale(v_sinangle, v_cosangle);
|
||||
// Precalculate a bunch of useful values we'll need in the fragment
|
||||
// shader.
|
||||
vec2 ang;
|
||||
// if (u_rotation_type.x < 0.5)
|
||||
// ang = vec2(0.0,angle.x);
|
||||
// else if (u_rotation_type.x < 1.5)
|
||||
// ang = vec2(angle.x,0.0);
|
||||
// else if (u_rotation_type.x < 2.5)
|
||||
// ang = vec2(0.0,-angle.x);
|
||||
// else
|
||||
// ang = vec2(-angle.x,0.0);
|
||||
ang = angle.xy;
|
||||
v_sinangle = sin(ang);
|
||||
v_cosangle = cos(ang);
|
||||
v_stretch = maxscale(v_sinangle, v_cosangle);
|
||||
|
||||
// The size of one texel, in texture-coordinates.
|
||||
v_one = 1.0 / u_tex_size0.xy;
|
||||
// The size of one texel, in texture-coordinates.
|
||||
v_one = 1.0 / u_tex_size0.xy;
|
||||
}
|
||||
|
@ -10,14 +10,14 @@ uniform vec4 u_aspect;
|
||||
|
||||
void main()
|
||||
{
|
||||
float wid = u_width.x*u_tex_size0.x/(320.*u_aspect.x);
|
||||
v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid));
|
||||
v_coeffs2 = exp(vec4(25.,36.,49.,64.)*vec4_splat(-1.0/wid/wid));
|
||||
float wid = u_width.x*u_tex_size0.x/(320.*u_aspect.x);
|
||||
v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid));
|
||||
v_coeffs2 = exp(vec4(25.,36.,49.,64.)*vec4_splat(-1.0/wid/wid));
|
||||
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
v_texCoord = a_texcoord0;
|
||||
v_texCoord = a_texcoord0;
|
||||
}
|
||||
|
@ -10,14 +10,14 @@ uniform vec4 u_aspect;
|
||||
|
||||
void main()
|
||||
{
|
||||
float wid = u_width.x*u_tex_size0.y/(320.*u_aspect.y);
|
||||
v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid));
|
||||
v_coeffs2 = exp(vec4(25.,36.,49.,64.)*vec4_splat(-1.0/wid/wid));
|
||||
float wid = u_width.x*u_tex_size0.y/(320.*u_aspect.y);
|
||||
v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid));
|
||||
v_coeffs2 = exp(vec4(25.,36.,49.,64.)*vec4_splat(-1.0/wid/wid));
|
||||
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
v_texCoord = a_texcoord0;
|
||||
v_texCoord = a_texcoord0;
|
||||
}
|
||||
|
@ -10,44 +10,44 @@ uniform vec4 u_lowpass_width;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
v_texCoord = a_texcoord0;
|
||||
v_texCoord = a_texcoord0;
|
||||
|
||||
// interpret the cutoff and width as target resolutions in pixels per scanline
|
||||
// include factor of 1/2 because max frequency at given resolution is Nyquist
|
||||
float a = 0.5 * u_lowpass_cutoff.x / u_tex_size0.x;
|
||||
float b = 0.5 * u_lowpass_width.x / u_tex_size0.x;
|
||||
float w0 = (a-0.5*b);
|
||||
float w1 = (a+0.5*b);
|
||||
// interpret the cutoff and width as target resolutions in pixels per scanline
|
||||
// include factor of 1/2 because max frequency at given resolution is Nyquist
|
||||
float a = 0.5 * u_lowpass_cutoff.x / u_tex_size0.x;
|
||||
float b = 0.5 * u_lowpass_width.x / u_tex_size0.x;
|
||||
float w0 = (a-0.5*b);
|
||||
float w1 = (a+0.5*b);
|
||||
|
||||
float two_pi = 6.283185307179586;
|
||||
vec3 n1 = vec3(1.0,2.0,3.0);
|
||||
vec4 n2 = vec4(4.0,5.0,6.0,7.0);
|
||||
float two_pi = 6.283185307179586;
|
||||
vec3 n1 = vec3(1.0,2.0,3.0);
|
||||
vec4 n2 = vec4(4.0,5.0,6.0,7.0);
|
||||
|
||||
// target frequency response:
|
||||
// 1 for w < w0
|
||||
// 0 for w > w1
|
||||
// linearly decreasing for w0 < w < w1
|
||||
// this will be approximated by including the lowest Fourier modes
|
||||
if (w0 > 0.5) { // no filtering
|
||||
v_lpcoeffs1 = vec4(1.0,0.0,0.0,0.0);
|
||||
v_lpcoeffs2 = vec4_splat(0.0);
|
||||
} else if (w1 > 0.5) { // don't reach zero
|
||||
// here the target has a nonzero response at the Nyquist frequency
|
||||
v_lpcoeffs1.x = w1 + w0 - (w1 - 0.5)*(w1 - 0.5)/(w1 - w0);
|
||||
v_lpcoeffs1.yzw = 2.0 / ( two_pi*two_pi*(w1-w0)*n1*n1 ) * ( cos(two_pi*w0*n1) - cos(two_pi*0.5*n1) );
|
||||
v_lpcoeffs2 = 2.0 / ( two_pi*two_pi*(w1-w0)*n2*n2 ) * ( cos(two_pi*w0*n2) - cos(two_pi*0.5*n2) );
|
||||
} else if (w1 == w0) { // sharp cutoff
|
||||
v_lpcoeffs1.x = 2.0 * w0;
|
||||
v_lpcoeffs1.yzw = 2.0 / ( two_pi * n1 ) * sin(two_pi*w0*n1);
|
||||
v_lpcoeffs2 = 2.0 / ( two_pi * n2 ) * sin(two_pi*w0*n2);
|
||||
} else {
|
||||
v_lpcoeffs1.x = w1 + w0;
|
||||
v_lpcoeffs1.yzw = 2.0 / ( two_pi*two_pi*(w1-w0)*n1*n1 ) * ( cos(two_pi*w0*n1) - cos(two_pi*w1*n1) );
|
||||
v_lpcoeffs2 = 2.0 / ( two_pi*two_pi*(w1-w0)*n2*n2 ) * ( cos(two_pi*w0*n2) - cos(two_pi*w1*n2) );
|
||||
}
|
||||
// target frequency response:
|
||||
// 1 for w < w0
|
||||
// 0 for w > w1
|
||||
// linearly decreasing for w0 < w < w1
|
||||
// this will be approximated by including the lowest Fourier modes
|
||||
if (w0 > 0.5) { // no filtering
|
||||
v_lpcoeffs1 = vec4(1.0,0.0,0.0,0.0);
|
||||
v_lpcoeffs2 = vec4_splat(0.0);
|
||||
} else if (w1 > 0.5) { // don't reach zero
|
||||
// here the target has a nonzero response at the Nyquist frequency
|
||||
v_lpcoeffs1.x = w1 + w0 - (w1 - 0.5)*(w1 - 0.5)/(w1 - w0);
|
||||
v_lpcoeffs1.yzw = 2.0 / ( two_pi*two_pi*(w1-w0)*n1*n1 ) * ( cos(two_pi*w0*n1) - cos(two_pi*0.5*n1) );
|
||||
v_lpcoeffs2 = 2.0 / ( two_pi*two_pi*(w1-w0)*n2*n2 ) * ( cos(two_pi*w0*n2) - cos(two_pi*0.5*n2) );
|
||||
} else if (w1 == w0) { // sharp cutoff
|
||||
v_lpcoeffs1.x = 2.0 * w0;
|
||||
v_lpcoeffs1.yzw = 2.0 / ( two_pi * n1 ) * sin(two_pi*w0*n1);
|
||||
v_lpcoeffs2 = 2.0 / ( two_pi * n2 ) * sin(two_pi*w0*n2);
|
||||
} else {
|
||||
v_lpcoeffs1.x = w1 + w0;
|
||||
v_lpcoeffs1.yzw = 2.0 / ( two_pi*two_pi*(w1-w0)*n1*n1 ) * ( cos(two_pi*w0*n1) - cos(two_pi*w1*n1) );
|
||||
v_lpcoeffs2 = 2.0 / ( two_pi*two_pi*(w1-w0)*n2*n2 ) * ( cos(two_pi*w0*n2) - cos(two_pi*w1*n2) );
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ uniform vec4 u_inv_view_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
v_texCoord = a_texcoord0;
|
||||
v_texCoord = a_texcoord0;
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ uniform vec4 u_inv_view_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
v_texCoord = a_texcoord0;
|
||||
v_texCoord = a_texcoord0;
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ uniform vec4 u_inv_view_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
// Do the standard vertex processing.
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
v_texCoord = a_texcoord0;
|
||||
v_texCoord = a_texcoord0;
|
||||
}
|
||||
|
@ -122,16 +122,16 @@ void main()
|
||||
else
|
||||
{
|
||||
p01 = 0.5 * (C4 + C5);
|
||||
}
|
||||
}
|
||||
|
||||
if ((c8 == d2) || (c3 == c4))
|
||||
{
|
||||
if ((c8 == d2) || (c3 == c4))
|
||||
{
|
||||
p10 = 0.25 * (3.0 * C4 + C7);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
p10 = 0.5 * (C7 + C8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -134,11 +134,11 @@ vec2 GetDistortedCoords(vec2 centerCoord, float amount, float amountCube)
|
||||
float r2 = centerCoord.x * centerCoord.x + centerCoord.y * centerCoord.y;
|
||||
float f = kcube == 0.0 ? 1.0 + r2 * k : 1.0 + r2 * (k + kcube * sqrt(r2));
|
||||
|
||||
// fit screen bounds
|
||||
// fit screen bounds
|
||||
f /= 1.0 + amount * 0.25 + amountCube * 0.125;
|
||||
|
||||
// apply cubic distortion factor
|
||||
centerCoord *= f;
|
||||
centerCoord *= f;
|
||||
|
||||
return centerCoord;
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ void main()
|
||||
|
||||
vec2 index;
|
||||
index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) +
|
||||
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
|
||||
dot(pattern[2], vec3(32.0, 64.0, 128.0));
|
||||
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
|
||||
dot(pattern[2], vec3(32.0, 64.0, 128.0));
|
||||
index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE));
|
||||
|
||||
vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE));
|
||||
|
@ -60,8 +60,8 @@ void main()
|
||||
|
||||
vec2 index;
|
||||
index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) +
|
||||
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
|
||||
dot(pattern[2], vec3(32.0, 64.0, 128.0));
|
||||
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
|
||||
dot(pattern[2], vec3(32.0, 64.0, 128.0));
|
||||
index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE));
|
||||
|
||||
vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE));
|
||||
|
@ -60,8 +60,8 @@ void main()
|
||||
|
||||
vec2 index;
|
||||
index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) +
|
||||
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
|
||||
dot(pattern[2], vec3(32.0, 64.0, 128.0));
|
||||
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
|
||||
dot(pattern[2], vec3(32.0, 64.0, 128.0));
|
||||
index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE));
|
||||
|
||||
vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE));
|
||||
|
@ -22,85 +22,85 @@ uniform vec4 u_subpixsize;
|
||||
|
||||
vec3 fetch_offset(vec2 coord, vec2 offset)
|
||||
{
|
||||
vec2 x = coord + offset;
|
||||
vec3 col = texture2D(s_tex, x).rgb;
|
||||
vec3 col2 = pow(vec3_splat(u_gain.x) * col + vec3_splat(u_blacklevel.x), vec3_splat(u_LCDgamma.x)) + vec3_splat(u_ambient.x);
|
||||
// want zero for outside pixels
|
||||
vec4 b = step(0.0,vec4(x.x,x.y,1.0-x.x,1.0-x.y));
|
||||
return vec3_splat(b.x*b.y*b.z*b.w) * col2;
|
||||
vec2 x = coord + offset;
|
||||
vec3 col = texture2D(s_tex, x).rgb;
|
||||
vec3 col2 = pow(vec3_splat(u_gain.x) * col + vec3_splat(u_blacklevel.x), vec3_splat(u_LCDgamma.x)) + vec3_splat(u_ambient.x);
|
||||
// want zero for outside pixels
|
||||
vec4 b = step(0.0,vec4(x.x,x.y,1.0-x.x,1.0-x.y));
|
||||
return vec3_splat(b.x*b.y*b.z*b.w) * col2;
|
||||
}
|
||||
|
||||
float intsmear_func(float z, float c1, float c2, float c3, float c4, float c5, float c6)
|
||||
{
|
||||
float z2 = z*z;
|
||||
// both cases have c0=1
|
||||
return z * (1.0 + z2*(c1 + z2*(c2 + z2*(c3 + z2*(c4 + z2*(c5 + z2*c6))))));
|
||||
float z2 = z*z;
|
||||
// both cases have c0=1
|
||||
return z * (1.0 + z2*(c1 + z2*(c2 + z2*(c3 + z2*(c4 + z2*(c5 + z2*c6))))));
|
||||
}
|
||||
|
||||
float intsmear_fx(float z)
|
||||
{
|
||||
// integral of (1 - x^2 - x^4 + x^6)^2
|
||||
return intsmear_func(z, -2.0/3.0, -1.0/5.0, 4.0/7.0, -1.0/9.0, -2.0/11.0, 1.0/13.0);
|
||||
// integral of (1 - x^2 - x^4 + x^6)^2
|
||||
return intsmear_func(z, -2.0/3.0, -1.0/5.0, 4.0/7.0, -1.0/9.0, -2.0/11.0, 1.0/13.0);
|
||||
}
|
||||
|
||||
float intsmear_fy(float z)
|
||||
{
|
||||
// integral of (1 - 2x^4 + x^6)^2
|
||||
return intsmear_func(z, 0.0, -4.0/5.0, 2.0/7.0, 4.0/9.0, -4.0/11.0, 1.0/13.0);
|
||||
// integral of (1 - 2x^4 + x^6)^2
|
||||
return intsmear_func(z, 0.0, -4.0/5.0, 2.0/7.0, 4.0/9.0, -4.0/11.0, 1.0/13.0);
|
||||
}
|
||||
|
||||
float intsmear_x(float x, float dx, float d)
|
||||
{
|
||||
float zl = clamp((x-dx*0.5)/d,-1.0,1.0);
|
||||
float zh = clamp((x+dx*0.5)/d,-1.0,1.0);
|
||||
return d * ( intsmear_fx(zh) - intsmear_fx(zl) )/dx;
|
||||
float zl = clamp((x-dx*0.5)/d,-1.0,1.0);
|
||||
float zh = clamp((x+dx*0.5)/d,-1.0,1.0);
|
||||
return d * ( intsmear_fx(zh) - intsmear_fx(zl) )/dx;
|
||||
}
|
||||
float intsmear_y(float x, float dx, float d)
|
||||
{
|
||||
float zl = clamp((x-dx*0.5)/d,-1.0,1.0);
|
||||
float zh = clamp((x+dx*0.5)/d,-1.0,1.0);
|
||||
return d * ( intsmear_fy(zh) - intsmear_fy(zl) )/dx;
|
||||
float zl = clamp((x-dx*0.5)/d,-1.0,1.0);
|
||||
float zh = clamp((x+dx*0.5)/d,-1.0,1.0);
|
||||
return d * ( intsmear_fy(zh) - intsmear_fy(zl) )/dx;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 cr = pow(u_rsubpix.rgb, vec3_splat(u_monitorgamma.x));
|
||||
vec3 cg = pow(u_gsubpix.rgb, vec3_splat(u_monitorgamma.x));
|
||||
vec3 cb = pow(u_bsubpix.rgb, vec3_splat(u_monitorgamma.x));
|
||||
vec3 cr = pow(u_rsubpix.rgb, vec3_splat(u_monitorgamma.x));
|
||||
vec3 cg = pow(u_gsubpix.rgb, vec3_splat(u_monitorgamma.x));
|
||||
vec3 cb = pow(u_bsubpix.rgb, vec3_splat(u_monitorgamma.x));
|
||||
|
||||
vec2 tl = v_texcoord0 * u_tex_size0.xy - vec2(0.5,0.5);
|
||||
vec2 tli = floor(tl);
|
||||
float subpix = fract(tl.x) * 3.0;
|
||||
float rsubpix = u_tex_size0.x / u_quad_dims.x * 3.0;
|
||||
vec2 tl = v_texcoord0 * u_tex_size0.xy - vec2(0.5,0.5);
|
||||
vec2 tli = floor(tl);
|
||||
float subpix = fract(tl.x) * 3.0;
|
||||
float rsubpix = u_tex_size0.x / u_quad_dims.x * 3.0;
|
||||
|
||||
vec3 lcol, rcol;
|
||||
lcol = vec3(intsmear_x(subpix+1.0, rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix , rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix-1.0, rsubpix, 3.0*u_subpixsize.x));
|
||||
rcol = vec3(intsmear_x(subpix-2.0, rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix-3.0, rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix-4.0, rsubpix, 3.0*u_subpixsize.x));
|
||||
vec3 lcol, rcol;
|
||||
lcol = vec3(intsmear_x(subpix+1.0, rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix , rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix-1.0, rsubpix, 3.0*u_subpixsize.x));
|
||||
rcol = vec3(intsmear_x(subpix-2.0, rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix-3.0, rsubpix, 3.0*u_subpixsize.x),
|
||||
intsmear_x(subpix-4.0, rsubpix, 3.0*u_subpixsize.x));
|
||||
|
||||
if (u_BGR.x > 0.5) {
|
||||
lcol.rgb = lcol.bgr;
|
||||
rcol.rgb = rcol.bgr;
|
||||
}
|
||||
if (u_BGR.x > 0.5) {
|
||||
lcol.rgb = lcol.bgr;
|
||||
rcol.rgb = rcol.bgr;
|
||||
}
|
||||
|
||||
float tcol, bcol;
|
||||
subpix = fract(tl.y);
|
||||
rsubpix = u_tex_size0.y / u_quad_dims.y;
|
||||
tcol = intsmear_y(subpix ,rsubpix, u_subpixsize.y);
|
||||
bcol = intsmear_y(subpix-1.0,rsubpix, u_subpixsize.y);
|
||||
float tcol, bcol;
|
||||
subpix = fract(tl.y);
|
||||
rsubpix = u_tex_size0.y / u_quad_dims.y;
|
||||
tcol = intsmear_y(subpix ,rsubpix, u_subpixsize.y);
|
||||
bcol = intsmear_y(subpix-1.0,rsubpix, u_subpixsize.y);
|
||||
|
||||
tl = (tli + vec2_splat(0.5)) / u_tex_size0.xy;
|
||||
vec2 one = vec2_splat(1.0) / u_tex_size0.xy;
|
||||
tl = (tli + vec2_splat(0.5)) / u_tex_size0.xy;
|
||||
vec2 one = vec2_splat(1.0) / u_tex_size0.xy;
|
||||
|
||||
vec3 ul = fetch_offset(tl, vec2(0,0) ) * lcol * vec3_splat(tcol);
|
||||
vec3 br = fetch_offset(tl, one ) * rcol * vec3_splat(bcol);
|
||||
vec3 bl = fetch_offset(tl, vec2(0,one.y)) * lcol * vec3_splat(bcol);
|
||||
vec3 ur = fetch_offset(tl, vec2(one.x,0)) * rcol * vec3_splat(tcol);
|
||||
vec3 ul = fetch_offset(tl, vec2(0,0) ) * lcol * vec3_splat(tcol);
|
||||
vec3 br = fetch_offset(tl, one ) * rcol * vec3_splat(bcol);
|
||||
vec3 bl = fetch_offset(tl, vec2(0,one.y)) * lcol * vec3_splat(bcol);
|
||||
vec3 ur = fetch_offset(tl, vec2(one.x,0)) * rcol * vec3_splat(tcol);
|
||||
|
||||
vec3 csum = ul + br + bl + ur;
|
||||
vec3 col = mul(mtxFromCols(u_rsubpix.rgb, u_gsubpix.rgb, u_bsubpix.rgb), csum);
|
||||
gl_FragColor = vec4(pow(col, vec3_splat(1.0/u_monitorgamma.x)), 1.0);
|
||||
vec3 csum = ul + br + bl + ur;
|
||||
vec3 col = mul(mtxFromCols(u_rsubpix.rgb, u_gsubpix.rgb, u_bsubpix.rgb), csum);
|
||||
gl_FragColor = vec4(pow(col, vec3_splat(1.0/u_monitorgamma.x)), 1.0);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ uniform vec4 u_persistence;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 screen = texture2D(s_screen , v_texcoord0);
|
||||
vec4 motionblur = texture2D(s_motionblur, v_texcoord0);
|
||||
vec4 screen = texture2D(s_screen , v_texcoord0);
|
||||
vec4 motionblur = texture2D(s_motionblur, v_texcoord0);
|
||||
|
||||
gl_FragColor = mix(screen, motionblur, u_persistence.x);
|
||||
gl_FragColor = mix(screen, motionblur, u_persistence.x);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ uniform vec4 DIFF_THRESH1;
|
||||
|
||||
vec3 df3(vec3 c1, vec3 c2)
|
||||
{
|
||||
return abs(c1 - c2);
|
||||
return abs(c1 - c2);
|
||||
}
|
||||
|
||||
bvec3 le3(vec3 A, vec3 B, vec3 param)
|
||||
|
@ -20,7 +20,7 @@ uniform vec4 DIFF_THRESH2;
|
||||
|
||||
vec3 df3(vec3 c1, vec3 c2)
|
||||
{
|
||||
return abs(c1 - c2);
|
||||
return abs(c1 - c2);
|
||||
}
|
||||
|
||||
bvec3 le3(vec3 A, vec3 B, vec3 param)
|
||||
|
@ -13,7 +13,7 @@ uniform vec4 u_inv_view_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
|
@ -13,7 +13,7 @@ uniform vec4 u_inv_view_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
|
@ -13,7 +13,7 @@ uniform vec4 u_inv_view_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
|
@ -13,7 +13,7 @@ uniform vec4 u_inv_view_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 300
|
||||
gl_Position.xy += u_inv_view_dims.xy * gl_Position.w;
|
||||
#endif
|
||||
|
@ -49,7 +49,7 @@ void main()
|
||||
// D E F
|
||||
// H
|
||||
|
||||
v_texcoord1 = vec4(1.0 / u_tex_size0.xy, 0.0, 0.0); // F H
|
||||
v_texcoord1 = vec4(1.0 / u_tex_size0.xy, 0.0, 0.0); // F H
|
||||
|
||||
v_color0 = a_color0;
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
/*
|
||||
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.
|
||||
@ -47,12 +47,12 @@ float d(vec2 pt1, vec2 pt2)
|
||||
|
||||
vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
|
||||
vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
vec4 resampler(vec4 x)
|
||||
|
@ -95,23 +95,23 @@ float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3
|
||||
|
||||
vec4 min4(vec4 a, vec4 b, vec4 c, vec4 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
|
||||
vec4 max4(vec4 a, vec4 b, vec4 c, vec4 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
//Skip pixels on wrong grid
|
||||
vec2 fraction = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES);
|
||||
if (fraction.x < 0.5 || fraction.y < 0.5)
|
||||
{
|
||||
gl_FragColor = texture2D(s0, v_texcoord0);
|
||||
return;
|
||||
}
|
||||
if (fraction.x < 0.5 || fraction.y < 0.5)
|
||||
{
|
||||
gl_FragColor = texture2D(s0, v_texcoord0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES) + vec2(0.5, 0.5)) * XBR_RES / u_tex_size0.xy;
|
||||
|
||||
|
@ -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