Reinstate scale param for bgfx texture, nw

This commit is contained in:
therealmogminer@gmail.com 2016-03-30 03:27:49 +02:00
parent 07abe5ebc1
commit 59e129f599
7 changed files with 49 additions and 36 deletions

View File

@ -89,14 +89,14 @@
{ "type": "color", "name": "phosphor", "text": "Phosphor Persistence, ", "default": [ 45, 45, 45 ], "max": [ 100, 100, 100 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_alpha", "text": "Scanline Amount", "default": 60, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_alpha", "text": "Scanline Amount", "default": 80, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_scale", "text": "Overall Scanline Scale", "default": 100, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_bright_scale", "text": "Scanline Brightness Scale", "default": 200, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_bright_offset", "text": "Scanline Brightness Offset", "default": 0, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_jitter_amount", "text": "Scanline Jitter Amount", "default": 0, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_height", "text": "Individual Scanline Scale", "default": 100, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_variation", "text": "Scanline Variation", "default": 100, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "shadow_alpha", "text": "Shadow Mask Amount", "default": 40, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "shadow_alpha", "text": "Shadow Mask Amount", "default": 20, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_count", "text": "Shadow Mask Pixel Count ", "default": [ 12, 12 ], "max": [ 128, 128 ], "min": [ 1, 1 ], "step": 1, "scale": 1.0, "format": "%3f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_size", "text": "Shadow Mask UV Size ", "default": [ 500, 500 ], "max": [ 1000, 1000 ], "min": [ 0, 0 ], "step": 1, "scale": 0.001, "format": "%1.4f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_offset", "text": "Shadow Mask UV Offset ", "default": [ 0, 0 ], "max": [ 1000, 1000 ], "min": [ 0, 0 ], "step": 1, "scale": 0.001, "format": "%1.4f", "screen": "crt" },
@ -152,9 +152,9 @@
// values: true, false
// default: true
//
// oversample (optional): Double the internal size of this render target. Certain effects benefit from operating at a higher internal resolution. If you're not sure, leave it as false.
// values: true, false
// default: false
// scale (optional): Multiply the internal size of this render target by this amount. Certain effects benefit from operating at a higher internal resolution. If you're not sure, omit it.
// values: Any integer value
// default: 1
{
"name": "ntsc",
"mode": "guest",
@ -168,7 +168,12 @@
},
{ "name": "internal",
"mode": "native",
"oversample": true,
"scale": 2,
"doublebuffer": true
},
{ "name": "previous",
"mode": "native",
"scale": 2,
"doublebuffer": true
}
],
@ -252,6 +257,10 @@
//
// option (optional): The name of any MAME option, which will have its value fetched and used as the name of a PNG to load from the artwork directory.
// value: Any valid MAME INI option name.
//
// bilinear (optional, texture and target only): Whether to apply bilinear filtering to the sampler.
// values: true, false
// default: true
{ "sampler": "s_tex", "texture": "screen" }
],

View File

@ -59,6 +59,7 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
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;
std::string texture_name = "";
if (has_texture)
@ -66,7 +67,9 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
texture_name = input["texture"].GetString();
if (texture_name != "screen")
{
bgfx_texture* texture = textures.create_png_texture(options.art_path(), texture_name, texture_name, 0, screen_index);
bool bilinear = get_bool(input, "bilinear", true);
uint32_t flags = bilinear ? 0 : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT);
bgfx_texture* texture = textures.create_png_texture(options.art_path(), texture_name, texture_name, flags, screen_index);
if (texture == nullptr)
{
return nullptr;
@ -79,8 +82,10 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
}
else if (has_option)
{
bool bilinear = get_bool(input, "bilinear", true);
uint32_t flags = bilinear ? 0 : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT);
texture_name = input["option"].GetString();
bgfx_texture* texture = textures.create_png_texture(options.art_path(), options.value(texture_name.c_str()), texture_name, 0, screen_index);
bgfx_texture* texture = textures.create_png_texture(options.art_path(), options.value(texture_name.c_str()), texture_name, flags, screen_index);
if (texture == nullptr)
{
return nullptr;

View File

@ -10,7 +10,7 @@
#include "target.h"
bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, bool smooth, uint32_t screen)
bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, uint16_t scale, uint32_t screen)
: m_name(name)
, m_format(format)
, m_targets(nullptr)
@ -20,7 +20,7 @@ bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uin
, m_double_buffer(double_buffer)
, m_style(style)
, m_filter(filter)
, m_smooth(smooth)
, m_scale(scale)
, m_screen(screen)
, m_current_page(0)
, m_initialized(false)
@ -28,11 +28,8 @@ bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uin
{
if (m_width > 0 && m_height > 0)
{
if (smooth)
{
m_width *= 2;
m_height *= 2;
}
m_width *= m_scale;
m_height *= m_scale;
uint32_t wrap_mode = BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP;
uint32_t filter_mode = filter ? (BGFX_TEXTURE_MIN_ANISOTROPIC | BGFX_TEXTURE_MAG_ANISOTROPIC) : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT);
@ -60,7 +57,6 @@ bgfx_target::bgfx_target(void *handle, uint16_t width, uint16_t height)
, m_double_buffer(false)
, m_style(TARGET_STYLE_CUSTOM)
, m_filter(false)
, m_smooth(false)
, m_screen(-1)
, m_current_page(0)
, m_initialized(true)

View File

@ -27,7 +27,7 @@ enum
class bgfx_target : public bgfx_texture_handle_provider
{
public:
bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, bool smooth, uint32_t screen);
bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, uint16_t scale, uint32_t screen);
bgfx_target(void *handle, uint16_t width, uint16_t height);
virtual ~bgfx_target();
@ -40,7 +40,7 @@ public:
bool double_buffered() const { return m_double_buffer; }
uint32_t style() const { return m_style; }
bool filter() const { return m_filter; }
bool smooth() const { return m_smooth; }
uint16_t scale() const { return m_scale; }
uint32_t screen_index() const { return m_screen; }
// bgfx_texture_handle_provider
@ -62,7 +62,7 @@ private:
bool m_double_buffer;
uint32_t m_style;
bool m_filter;
bool m_smooth;
uint16_t m_scale;
int32_t m_screen;

View File

@ -45,9 +45,9 @@ target_manager::~target_manager()
}
}
bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, uint32_t style, bool double_buffer, bool filter, bool smooth, uint32_t screen)
bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, uint16_t scale, uint32_t screen)
{
bgfx_target* target = new bgfx_target(name, format, width, height, style, double_buffer, filter, smooth, screen);
bgfx_target* target = new bgfx_target(name, format, width, height, style, double_buffer, filter, scale, screen);
m_targets[name + std::to_string(screen)] = target;
@ -56,7 +56,7 @@ bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat
return target;
}
bgfx_target* target_manager::create_backbuffer(void *handle, uint32_t width, uint32_t height)
bgfx_target* target_manager::create_backbuffer(void *handle, uint16_t width, uint16_t height)
{
bgfx_target* target = new bgfx_target(handle, width, height);
m_targets["backbuffer"] = target;
@ -115,12 +115,12 @@ void target_manager::rebuild_targets(uint32_t screen, uint32_t style)
const bgfx::TextureFormat::Enum format = target->format();
const bool double_buffered = target->double_buffered();
const bool filter = target->filter();
const bool smooth = target->smooth();
const uint16_t scale = target->scale();
const uint16_t width(sizes[screen].width());
const uint16_t height(sizes[screen].height());
delete target;
create_target(name, format, width, height, style, double_buffered, filter, smooth, screen);
create_target(name, format, width, height, style, double_buffered, filter, scale, screen);
}
}
@ -140,14 +140,13 @@ void target_manager::update_screen_count(uint32_t count)
{
for (uint32_t screen = old_count; screen < m_screen_count; screen++)
{
create_target_if_nonexistent(screen, "output", false, false, false, TARGET_STYLE_NATIVE);
create_target_if_nonexistent(screen, "previous", false, false, false, TARGET_STYLE_NATIVE);
create_target_if_nonexistent(screen, "output", false, false, TARGET_STYLE_NATIVE);
}
}
}
}
void target_manager::create_target_if_nonexistent(uint32_t screen, std::string name, bool double_buffered, bool filter, bool smooth, uint32_t style)
void target_manager::create_target_if_nonexistent(uint32_t screen, std::string name, bool double_buffered, bool filter, uint32_t style)
{
if (style == TARGET_STYLE_CUSTOM) return;
@ -160,5 +159,5 @@ void target_manager::create_target_if_nonexistent(uint32_t screen, std::string n
uint16_t width(sizes[screen].width());
uint16_t height(sizes[screen].height());
create_target(name, bgfx::TextureFormat::RGBA8, width, height, style, double_buffered, filter, smooth, screen);
create_target(name, bgfx::TextureFormat::RGBA8, width, height, style, double_buffered, filter, 1, screen);
}

View File

@ -30,8 +30,8 @@ public:
target_manager(texture_manager& textures);
~target_manager();
bgfx_target* create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, uint32_t style, bool double_buffer, bool filter, bool smooth, uint32_t screen);
bgfx_target* create_backbuffer(void *handle, uint32_t width, uint32_t height);
bgfx_target* create_target(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t style, bool double_buffer, bool filter, uint16_t scale, uint32_t screen);
bgfx_target* create_backbuffer(void *handle, uint16_t width, uint16_t height);
void update_target_sizes(uint32_t screen, uint16_t width, uint16_t height, uint32_t style);
void update_screen_count(uint32_t count);
@ -41,7 +41,7 @@ public:
private:
void rebuild_targets(uint32_t screen, uint32_t style);
void create_target_if_nonexistent(uint32_t screen, std::string name, bool double_buffered, bool filter, bool smooth, uint32_t style);
void create_target_if_nonexistent(uint32_t screen, std::string name, bool double_buffered, bool filter, uint32_t style);
std::map<std::string, bgfx_target*> m_targets;
texture_manager& m_textures;

View File

@ -32,7 +32,11 @@ bool target_reader::read_from_value(const Value& value, std::string prefix, targ
uint32_t mode = uint32_t(get_enum_from_value(value, "mode", TARGET_STYLE_NATIVE, STYLE_NAMES, STYLE_COUNT));
bool bilinear = get_bool(value, "bilinear", true);
bool double_buffer = get_bool(value, "doublebuffer", true);
bool smooth = get_bool(value, "oversample", false);
int scale = 1;
if (value.HasMember("scale"))
{
scale = int(floor(value["scale"].GetDouble() + 0.5));
}
uint16_t width = 0;
uint16_t height = 0;
@ -47,12 +51,12 @@ bool target_reader::read_from_value(const Value& value, std::string prefix, targ
if (!READER_CHECK(value["width"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'width' must be a number\n").c_str())) return false;
if (!READER_CHECK(value.HasMember("height"), (prefix + "Target '" + target_name + "': Must have numeric value 'height'\n").c_str())) return false;
if (!READER_CHECK(value["height"].IsNumber(), (prefix + "Target '" + target_name + "': Value 'height' must be a number\n").c_str())) return false;
width = uint32_t(value["width"].GetDouble());
height = uint32_t(value["height"].GetDouble());
width = uint16_t(value["width"].GetDouble());
height = uint16_t(value["height"].GetDouble());
break;
}
targets.create_target(target_name, bgfx::TextureFormat::RGBA8, width, height, mode, double_buffer, bilinear, smooth, screen_index);
targets.create_target(target_name, bgfx::TextureFormat::RGBA8, width, height, mode, double_buffer, bilinear, scale, screen_index);
return true;
}
@ -64,6 +68,6 @@ bool target_reader::validate_parameters(const Value& value, std::string prefix)
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("oversample") || value["oversample"].IsBool(), (prefix + "Value 'oversample' 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;
return true;
}