summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-02-18 23:10:22 +0100
committer therealmogminer@gmail.com <therealmogminer@gmail.com>2016-02-21 03:03:28 +0100
commiteca47070a5894d7e95bde0ad877eddada2733393 (patch)
tree203af4f71eade5b36ad2d649bbaedb01e06e3b28 /src/osd
parent664a0aee905f37059ae371757f789e2f0ebbfb13 (diff)
More work on targets, nw
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/render/bgfx/effectreader.cpp4
-rw-r--r--src/osd/modules/render/bgfx/target.cpp6
-rw-r--r--src/osd/modules/render/bgfx/target.h1
-rw-r--r--src/osd/modules/render/bgfx/targetmanager.cpp11
-rw-r--r--src/osd/modules/render/bgfx/targetmanager.h1
-rw-r--r--src/osd/modules/render/drawbgfx.cpp101
-rw-r--r--src/osd/modules/render/drawbgfx.h9
-rw-r--r--src/osd/modules/render/drawd3d.h8
-rw-r--r--src/osd/osdepend.h2
9 files changed, 77 insertions, 66 deletions
diff --git a/src/osd/modules/render/bgfx/effectreader.cpp b/src/osd/modules/render/bgfx/effectreader.cpp
index 0fe24ec92dc..a663b6275cd 100644
--- a/src/osd/modules/render/bgfx/effectreader.cpp
+++ b/src/osd/modules/render/bgfx/effectreader.cpp
@@ -64,6 +64,6 @@ void effect_reader::validate_parameters(const Value& value)
{
assert(value["pixel"].IsString());
}
- assert(value.HasMember("uniform"));
- assert(value["uniform"].IsArray());
+ assert(value.HasMember("uniforms"));
+ assert(value["uniforms"].IsArray());
} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/target.cpp b/src/osd/modules/render/bgfx/target.cpp
index b45ccde519e..3b732d6628b 100644
--- a/src/osd/modules/render/bgfx/target.cpp
+++ b/src/osd/modules/render/bgfx/target.cpp
@@ -6,6 +6,12 @@ bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uin
m_target = bgfx::createFrameBuffer(1, &m_handle, false);
}
+bgfx_target::bgfx_target(std::string name, void *handle, uint32_t width, uint32_t height)
+ : bgfx_texture(name, bgfx::TextureFormat::RGBA8, width, height, nullptr, BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT)
+{
+ m_target = bgfx::createFrameBuffer(handle, width, height);
+}
+
bgfx_target::~bgfx_target()
{
bgfx::destroyFrameBuffer(m_target);
diff --git a/src/osd/modules/render/bgfx/target.h b/src/osd/modules/render/bgfx/target.h
index e00b965bb57..75e4152be9e 100644
--- a/src/osd/modules/render/bgfx/target.h
+++ b/src/osd/modules/render/bgfx/target.h
@@ -9,6 +9,7 @@ class bgfx_target : public bgfx_texture
{
public:
bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, bool filter = false);
+ bgfx_target(std::string name, void *handle, uint32_t width, uint32_t height);
virtual ~bgfx_target();
// Getters
diff --git a/src/osd/modules/render/bgfx/targetmanager.cpp b/src/osd/modules/render/bgfx/targetmanager.cpp
index 8f9a0a6bf8b..f0f1a6f990d 100644
--- a/src/osd/modules/render/bgfx/targetmanager.cpp
+++ b/src/osd/modules/render/bgfx/targetmanager.cpp
@@ -14,6 +14,7 @@ target_manager::~target_manager()
bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, bool filter)
{
+ printf("Creating %s\n", name.c_str());
bgfx_target* target = new bgfx_target(name, format, width, height, filter);
m_targets[name] = target;
@@ -21,6 +22,16 @@ bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat
return target;
}
+bgfx_target* target_manager::create_target(std::string name, void *handle, uint32_t width, uint32_t height)
+{
+ printf("Creating %s\n", name.c_str());
+ bgfx_target* target = new bgfx_target(name, handle, width, height);
+ m_targets[name] = target;
+
+ m_textures.add_texture(name, target);
+ return target;
+}
+
bgfx_target* target_manager::target(std::string name)
{
std::map<std::string, bgfx_target*>::iterator iter = m_targets.find(name);
diff --git a/src/osd/modules/render/bgfx/targetmanager.h b/src/osd/modules/render/bgfx/targetmanager.h
index 4cf3fea3637..cd17c4ccb3c 100644
--- a/src/osd/modules/render/bgfx/targetmanager.h
+++ b/src/osd/modules/render/bgfx/targetmanager.h
@@ -18,6 +18,7 @@ public:
~target_manager();
bgfx_target* create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, bool filter = false);
+ bgfx_target* create_target(std::string name, void *handle, uint32_t width, uint32_t height);
// Getters
bgfx_target* target(std::string name);
diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp
index 45c9486f19a..f2d58f4e4d5 100644
--- a/src/osd/modules/render/drawbgfx.cpp
+++ b/src/osd/modules/render/drawbgfx.cpp
@@ -32,10 +32,12 @@
#include "drawbgfx.h"
#include "bgfx/texturemanager.h"
+#include "bgfx/targetmanager.h"
#include "bgfx/shadermanager.h"
#include "bgfx/effectmanager.h"
#include "bgfx/effect.h"
#include "bgfx/texture.h"
+#include "bgfx/target.h"
//============================================================
// DEBUGGING
@@ -94,8 +96,8 @@ int renderer_bgfx::create()
// create renderer
osd_dim wdim = window().get_size();
- m_width = wdim.width();
- m_height = wdim.height();
+ m_width[window().m_index] = wdim.width();
+ m_height[window().m_index] = wdim.height();
if (window().m_index == 0)
{
#ifdef OSD_WINDOWS
@@ -104,46 +106,39 @@ int renderer_bgfx::create()
bgfx::sdlSetWindow(window().sdl_window());
#endif
bgfx::init();
- bgfx::reset(m_width, m_height, video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
+ bgfx::reset(m_width[window().m_index], m_height[window().m_index], video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
// Enable debug text.
bgfx::setDebug(BGFX_DEBUG_TEXT); //BGFX_DEBUG_STATS
- m_dimensions = osd_dim(m_width, m_height);
- }
- else
- {
-#ifdef OSD_WINDOWS
- m_framebuffer = bgfx::createFrameBuffer(window().m_hwnd, m_width, m_height);
-#else
- m_framebuffer = bgfx::createFrameBuffer(sdlNativeWindowHandle(window().sdl_window()), m_width, m_height);
-#endif
- bgfx::touch(window().m_index);
- }
+ m_dimensions = osd_dim(m_width[0], m_height[0]);
- ScreenVertex::init();
+ ScreenVertex::init();
+ }
m_textures = new texture_manager();
+ m_targets = new target_manager(*m_textures);
m_shaders = new shader_manager();
m_effects = new effect_manager(*m_shaders);
+ if (window().m_index != 0)
+ {
+#ifdef OSD_WINDOWS
+ m_framebuffer = m_targets->create_target("backbuffer", window().m_hwnd, m_width[window().m_index], m_height[window().m_index]);
+#else
+ m_framebuffer = m_targets->create_target("backbuffer", sdlNativeWindowHandle(window().sdl_window()), m_width[window().m_index], m_height[window().m_index]);
+#endif
+ bgfx::touch(window().m_index);
+ }
+
// Create program from shaders.
- printf("1\n"); fflush(stdout);
m_gui_effect[0] = m_effects->effect("gui_opaque");
- printf("2\n"); fflush(stdout);
m_gui_effect[1] = m_effects->effect("gui_blend");
- printf("3\n"); fflush(stdout);
m_gui_effect[2] = m_effects->effect("gui_multiply");
- printf("4\n"); fflush(stdout);
m_gui_effect[3] = m_effects->effect("gui_add");
- printf("5\n"); fflush(stdout);
m_screen_effect[0] = m_effects->effect("screen_opaque");
- printf("6\n"); fflush(stdout);
m_screen_effect[1] = m_effects->effect("screen_blend");
- printf("7\n"); fflush(stdout);
m_screen_effect[2] = m_effects->effect("screen_multiply");
- printf("8\n"); fflush(stdout);
m_screen_effect[3] = m_effects->effect("screen_add");
- printf("9\n"); fflush(stdout);
uint32_t flags = BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT;
m_texture_cache = m_textures->create_texture("#cache", bgfx::TextureFormat::RGBA8, CACHE_SIZE, CACHE_SIZE, nullptr, flags);
@@ -160,15 +155,11 @@ int renderer_bgfx::create()
renderer_bgfx::~renderer_bgfx()
{
- if (window().m_index > 0)
- {
- bgfx::destroyFrameBuffer(m_framebuffer);
- }
-
// Cleanup.
+ delete m_targets;
+ delete m_textures;
delete m_effects;
delete m_shaders;
- delete m_textures;
bgfx::shutdown();
}
@@ -741,32 +732,29 @@ int renderer_bgfx::draw(int update)
int index = window().m_index;
// Set view 0 default viewport.
osd_dim wdim = window().get_size();
- int width = wdim.width();
- int height = wdim.height();
+ m_width[index] = wdim.width();
+ m_height[index] = wdim.height();
if (index == 0)
{
- if ((m_dimensions != osd_dim(width, height)))
+ if ((m_dimensions != osd_dim(m_width[index], m_height[index])))
{
- bgfx::reset(width, height, video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
- m_dimensions = osd_dim(width, height);
+ bgfx::reset(m_width[index], m_height[index], video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
+ m_dimensions = osd_dim(m_width[index], m_height[index]);
}
}
else
{
- if ((m_dimensions != osd_dim(width, height)))
+ if ((m_dimensions != osd_dim(m_width[index], m_height[index])))
{
bgfx::reset(window().m_main->get_size().width(), window().m_main->get_size().height(), video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
- if (bgfx::isValid(m_framebuffer))
- {
- bgfx::destroyFrameBuffer(m_framebuffer);
- }
+ delete m_framebuffer;
#ifdef OSD_WINDOWS
- m_framebuffer = bgfx::createFrameBuffer(window().m_hwnd, width, height);
+ m_framebuffer = m_targets->create_target("backbuffer", window().m_hwnd, m_width[index], m_height[index]);
#else
- m_framebuffer = bgfx::createFrameBuffer(sdlNativeWindowHandle(window().sdl_window()), width, height);
+ m_framebuffer = m_targets->create_target("backbuffer", sdlNativeWindowHandle(window().sdl_window()), m_width[index], m_height[index]);
#endif
- bgfx::setViewFrameBuffer(index, m_framebuffer);
- m_dimensions = osd_dim(width, height);
+ bgfx::setViewFrameBuffer(index, m_framebuffer->target());
+ m_dimensions = osd_dim(m_width[index], m_height[index]);
bgfx::setViewClear(index
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
, 0x000000ff
@@ -779,12 +767,12 @@ int renderer_bgfx::draw(int update)
}
}
- if (index != 0)
- {
- bgfx::setViewFrameBuffer(index, m_framebuffer);
- }
- bgfx::setViewSeq(index, true);
- bgfx::setViewRect(index, 0, 0, width, height);
+ if (index != 0)
+ {
+ bgfx::setViewFrameBuffer(index, m_framebuffer->target());
+ }
+ bgfx::setViewSeq(index, true);
+ bgfx::setViewRect(index, 0, 0, m_width[index], m_height[index]);
// Setup view transform.
{
@@ -793,8 +781,8 @@ int renderer_bgfx::draw(int update)
float left = 0.0f;
float top = 0.0f;
- float right = width;
- float bottom = height;
+ float right = m_width[index];
+ float bottom = m_height[index];
float proj[16];
bx::mtxOrtho(proj, left, right, bottom, top, 0.0f, 100.0f);
bgfx::setViewTransform(index, view, proj);
@@ -806,10 +794,6 @@ int renderer_bgfx::draw(int update)
, 0
);
- // This dummy draw call is here to make sure that view 0 is cleared
- // if no other draw calls are submitted to view 0.
- bgfx::touch(index);
-
window().m_primlist->acquire_lock();
// Mark our texture atlas as dirty if we need to do so
@@ -839,6 +823,11 @@ int renderer_bgfx::draw(int update)
}
window().m_primlist->release_lock();
+
+ // This dummy draw call is here to make sure that view 0 is cleared
+ // if no other draw calls are submitted to view 0.
+ bgfx::touch(index);
+
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
if (index==0) bgfx::frame();
diff --git a/src/osd/modules/render/drawbgfx.h b/src/osd/modules/render/drawbgfx.h
index c0657921609..2cb26dd8eae 100644
--- a/src/osd/modules/render/drawbgfx.h
+++ b/src/osd/modules/render/drawbgfx.h
@@ -11,10 +11,12 @@
#include "binpacker.h"
class texture_manager;
+class target_manager;
class shader_manager;
class effect_manager;
class bgfx_texture;
class bgfx_effect;
+class bgfx_target;
/* sdl_info is the information about SDL for the current screen */
class renderer_bgfx : public osd_renderer
@@ -93,13 +95,14 @@ private:
const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(UINT32 format, int width, int height, int rowpixels, const rgb_t *palette, void *base);
UINT32 get_texture_hash(render_primitive *prim);
- bgfx::FrameBufferHandle m_framebuffer;
+ bgfx_target* m_framebuffer;
bgfx_texture* m_texture_cache;
// Original display_mode
osd_dim m_dimensions;
texture_manager* m_textures;
+ target_manager* m_targets;
shader_manager* m_shaders;
effect_manager* m_effects;
bgfx_effect* m_gui_effect[4];
@@ -109,8 +112,8 @@ private:
std::vector<rectangle_packer::packable_rectangle> m_texinfo;
rectangle_packer m_packer;
- uint32_t m_width;
- uint32_t m_height;
+ uint32_t m_width[16];
+ uint32_t m_height[16];
uint32_t m_white[16*16];
enum : uint16_t { CACHE_SIZE = 1024 };
enum : uint32_t { PACKABLE_SIZE = 128 };
diff --git a/src/osd/modules/render/drawd3d.h b/src/osd/modules/render/drawd3d.h
index 8ddb8acef54..35bd5f1843b 100644
--- a/src/osd/modules/render/drawd3d.h
+++ b/src/osd/modules/render/drawd3d.h
@@ -25,13 +25,13 @@
// TYPE DEFINITIONS
//============================================================
-class vertex;
+struct vertex;
class texture_info;
class texture_manager;
-class device;
-class vertex_buffer;
+struct device;
+struct vertex_buffer;
class shaders;
-class hlsl_options;
+struct hlsl_options;
class poly_info;
/* renderer is the information about Direct3D for the current screen */
diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h
index 9e19b1419b1..3e5b7d91e8f 100644
--- a/src/osd/osdepend.h
+++ b/src/osd/osdepend.h
@@ -41,7 +41,7 @@ public:
// ======================> osd_interface
-class slider_state;
+struct slider_state;
// description of the currently-running machine
class osd_interface