More work on targets, nw
This commit is contained in:
parent
664a0aee90
commit
eca47070a5
@ -64,6 +64,6 @@ void effect_reader::validate_parameters(const Value& value)
|
|||||||
{
|
{
|
||||||
assert(value["pixel"].IsString());
|
assert(value["pixel"].IsString());
|
||||||
}
|
}
|
||||||
assert(value.HasMember("uniform"));
|
assert(value.HasMember("uniforms"));
|
||||||
assert(value["uniform"].IsArray());
|
assert(value["uniforms"].IsArray());
|
||||||
}
|
}
|
@ -6,6 +6,12 @@ bgfx_target::bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uin
|
|||||||
m_target = bgfx::createFrameBuffer(1, &m_handle, false);
|
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_target::~bgfx_target()
|
||||||
{
|
{
|
||||||
bgfx::destroyFrameBuffer(m_target);
|
bgfx::destroyFrameBuffer(m_target);
|
||||||
|
@ -9,6 +9,7 @@ class bgfx_target : public bgfx_texture
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, bool filter = false);
|
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();
|
virtual ~bgfx_target();
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -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)
|
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);
|
bgfx_target* target = new bgfx_target(name, format, width, height, filter);
|
||||||
m_targets[name] = target;
|
m_targets[name] = target;
|
||||||
|
|
||||||
@ -21,6 +22,16 @@ bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat
|
|||||||
return target;
|
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)
|
bgfx_target* target_manager::target(std::string name)
|
||||||
{
|
{
|
||||||
std::map<std::string, bgfx_target*>::iterator iter = m_targets.find(name);
|
std::map<std::string, bgfx_target*>::iterator iter = m_targets.find(name);
|
||||||
|
@ -18,6 +18,7 @@ public:
|
|||||||
~target_manager();
|
~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, 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
|
// Getters
|
||||||
bgfx_target* target(std::string name);
|
bgfx_target* target(std::string name);
|
||||||
|
@ -32,10 +32,12 @@
|
|||||||
|
|
||||||
#include "drawbgfx.h"
|
#include "drawbgfx.h"
|
||||||
#include "bgfx/texturemanager.h"
|
#include "bgfx/texturemanager.h"
|
||||||
|
#include "bgfx/targetmanager.h"
|
||||||
#include "bgfx/shadermanager.h"
|
#include "bgfx/shadermanager.h"
|
||||||
#include "bgfx/effectmanager.h"
|
#include "bgfx/effectmanager.h"
|
||||||
#include "bgfx/effect.h"
|
#include "bgfx/effect.h"
|
||||||
#include "bgfx/texture.h"
|
#include "bgfx/texture.h"
|
||||||
|
#include "bgfx/target.h"
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// DEBUGGING
|
// DEBUGGING
|
||||||
@ -94,8 +96,8 @@ int renderer_bgfx::create()
|
|||||||
// create renderer
|
// create renderer
|
||||||
|
|
||||||
osd_dim wdim = window().get_size();
|
osd_dim wdim = window().get_size();
|
||||||
m_width = wdim.width();
|
m_width[window().m_index] = wdim.width();
|
||||||
m_height = wdim.height();
|
m_height[window().m_index] = wdim.height();
|
||||||
if (window().m_index == 0)
|
if (window().m_index == 0)
|
||||||
{
|
{
|
||||||
#ifdef OSD_WINDOWS
|
#ifdef OSD_WINDOWS
|
||||||
@ -104,46 +106,39 @@ int renderer_bgfx::create()
|
|||||||
bgfx::sdlSetWindow(window().sdl_window());
|
bgfx::sdlSetWindow(window().sdl_window());
|
||||||
#endif
|
#endif
|
||||||
bgfx::init();
|
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.
|
// Enable debug text.
|
||||||
bgfx::setDebug(BGFX_DEBUG_TEXT); //BGFX_DEBUG_STATS
|
bgfx::setDebug(BGFX_DEBUG_TEXT); //BGFX_DEBUG_STATS
|
||||||
m_dimensions = osd_dim(m_width, m_height);
|
m_dimensions = osd_dim(m_width[0], m_height[0]);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScreenVertex::init();
|
ScreenVertex::init();
|
||||||
|
}
|
||||||
|
|
||||||
m_textures = new texture_manager();
|
m_textures = new texture_manager();
|
||||||
|
m_targets = new target_manager(*m_textures);
|
||||||
m_shaders = new shader_manager();
|
m_shaders = new shader_manager();
|
||||||
m_effects = new effect_manager(*m_shaders);
|
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.
|
// Create program from shaders.
|
||||||
printf("1\n"); fflush(stdout);
|
|
||||||
m_gui_effect[0] = m_effects->effect("gui_opaque");
|
m_gui_effect[0] = m_effects->effect("gui_opaque");
|
||||||
printf("2\n"); fflush(stdout);
|
|
||||||
m_gui_effect[1] = m_effects->effect("gui_blend");
|
m_gui_effect[1] = m_effects->effect("gui_blend");
|
||||||
printf("3\n"); fflush(stdout);
|
|
||||||
m_gui_effect[2] = m_effects->effect("gui_multiply");
|
m_gui_effect[2] = m_effects->effect("gui_multiply");
|
||||||
printf("4\n"); fflush(stdout);
|
|
||||||
m_gui_effect[3] = m_effects->effect("gui_add");
|
m_gui_effect[3] = m_effects->effect("gui_add");
|
||||||
printf("5\n"); fflush(stdout);
|
|
||||||
|
|
||||||
m_screen_effect[0] = m_effects->effect("screen_opaque");
|
m_screen_effect[0] = m_effects->effect("screen_opaque");
|
||||||
printf("6\n"); fflush(stdout);
|
|
||||||
m_screen_effect[1] = m_effects->effect("screen_blend");
|
m_screen_effect[1] = m_effects->effect("screen_blend");
|
||||||
printf("7\n"); fflush(stdout);
|
|
||||||
m_screen_effect[2] = m_effects->effect("screen_multiply");
|
m_screen_effect[2] = m_effects->effect("screen_multiply");
|
||||||
printf("8\n"); fflush(stdout);
|
|
||||||
m_screen_effect[3] = m_effects->effect("screen_add");
|
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;
|
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);
|
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()
|
renderer_bgfx::~renderer_bgfx()
|
||||||
{
|
{
|
||||||
if (window().m_index > 0)
|
|
||||||
{
|
|
||||||
bgfx::destroyFrameBuffer(m_framebuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
|
delete m_targets;
|
||||||
|
delete m_textures;
|
||||||
delete m_effects;
|
delete m_effects;
|
||||||
delete m_shaders;
|
delete m_shaders;
|
||||||
delete m_textures;
|
|
||||||
|
|
||||||
bgfx::shutdown();
|
bgfx::shutdown();
|
||||||
}
|
}
|
||||||
@ -741,32 +732,29 @@ int renderer_bgfx::draw(int update)
|
|||||||
int index = window().m_index;
|
int index = window().m_index;
|
||||||
// Set view 0 default viewport.
|
// Set view 0 default viewport.
|
||||||
osd_dim wdim = window().get_size();
|
osd_dim wdim = window().get_size();
|
||||||
int width = wdim.width();
|
m_width[index] = wdim.width();
|
||||||
int height = wdim.height();
|
m_height[index] = wdim.height();
|
||||||
if (index == 0)
|
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);
|
bgfx::reset(m_width[index], m_height[index], video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
|
||||||
m_dimensions = osd_dim(width, height);
|
m_dimensions = osd_dim(m_width[index], m_height[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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);
|
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))
|
delete m_framebuffer;
|
||||||
{
|
|
||||||
bgfx::destroyFrameBuffer(m_framebuffer);
|
|
||||||
}
|
|
||||||
#ifdef OSD_WINDOWS
|
#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
|
#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
|
#endif
|
||||||
bgfx::setViewFrameBuffer(index, m_framebuffer);
|
bgfx::setViewFrameBuffer(index, m_framebuffer->target());
|
||||||
m_dimensions = osd_dim(width, height);
|
m_dimensions = osd_dim(m_width[index], m_height[index]);
|
||||||
bgfx::setViewClear(index
|
bgfx::setViewClear(index
|
||||||
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
|
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
|
||||||
, 0x000000ff
|
, 0x000000ff
|
||||||
@ -779,12 +767,12 @@ int renderer_bgfx::draw(int update)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != 0)
|
if (index != 0)
|
||||||
{
|
{
|
||||||
bgfx::setViewFrameBuffer(index, m_framebuffer);
|
bgfx::setViewFrameBuffer(index, m_framebuffer->target());
|
||||||
}
|
}
|
||||||
bgfx::setViewSeq(index, true);
|
bgfx::setViewSeq(index, true);
|
||||||
bgfx::setViewRect(index, 0, 0, width, height);
|
bgfx::setViewRect(index, 0, 0, m_width[index], m_height[index]);
|
||||||
|
|
||||||
// Setup view transform.
|
// Setup view transform.
|
||||||
{
|
{
|
||||||
@ -793,8 +781,8 @@ int renderer_bgfx::draw(int update)
|
|||||||
|
|
||||||
float left = 0.0f;
|
float left = 0.0f;
|
||||||
float top = 0.0f;
|
float top = 0.0f;
|
||||||
float right = width;
|
float right = m_width[index];
|
||||||
float bottom = height;
|
float bottom = m_height[index];
|
||||||
float proj[16];
|
float proj[16];
|
||||||
bx::mtxOrtho(proj, left, right, bottom, top, 0.0f, 100.0f);
|
bx::mtxOrtho(proj, left, right, bottom, top, 0.0f, 100.0f);
|
||||||
bgfx::setViewTransform(index, view, proj);
|
bgfx::setViewTransform(index, view, proj);
|
||||||
@ -806,10 +794,6 @@ int renderer_bgfx::draw(int update)
|
|||||||
, 0
|
, 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();
|
window().m_primlist->acquire_lock();
|
||||||
|
|
||||||
// Mark our texture atlas as dirty if we need to do so
|
// 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();
|
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
|
// Advance to next frame. Rendering thread will be kicked to
|
||||||
// process submitted rendering primitives.
|
// process submitted rendering primitives.
|
||||||
if (index==0) bgfx::frame();
|
if (index==0) bgfx::frame();
|
||||||
|
@ -11,10 +11,12 @@
|
|||||||
#include "binpacker.h"
|
#include "binpacker.h"
|
||||||
|
|
||||||
class texture_manager;
|
class texture_manager;
|
||||||
|
class target_manager;
|
||||||
class shader_manager;
|
class shader_manager;
|
||||||
class effect_manager;
|
class effect_manager;
|
||||||
class bgfx_texture;
|
class bgfx_texture;
|
||||||
class bgfx_effect;
|
class bgfx_effect;
|
||||||
|
class bgfx_target;
|
||||||
|
|
||||||
/* sdl_info is the information about SDL for the current screen */
|
/* sdl_info is the information about SDL for the current screen */
|
||||||
class renderer_bgfx : public osd_renderer
|
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);
|
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);
|
UINT32 get_texture_hash(render_primitive *prim);
|
||||||
|
|
||||||
bgfx::FrameBufferHandle m_framebuffer;
|
bgfx_target* m_framebuffer;
|
||||||
bgfx_texture* m_texture_cache;
|
bgfx_texture* m_texture_cache;
|
||||||
|
|
||||||
// Original display_mode
|
// Original display_mode
|
||||||
osd_dim m_dimensions;
|
osd_dim m_dimensions;
|
||||||
|
|
||||||
texture_manager* m_textures;
|
texture_manager* m_textures;
|
||||||
|
target_manager* m_targets;
|
||||||
shader_manager* m_shaders;
|
shader_manager* m_shaders;
|
||||||
effect_manager* m_effects;
|
effect_manager* m_effects;
|
||||||
bgfx_effect* m_gui_effect[4];
|
bgfx_effect* m_gui_effect[4];
|
||||||
@ -109,8 +112,8 @@ private:
|
|||||||
std::vector<rectangle_packer::packable_rectangle> m_texinfo;
|
std::vector<rectangle_packer::packable_rectangle> m_texinfo;
|
||||||
rectangle_packer m_packer;
|
rectangle_packer m_packer;
|
||||||
|
|
||||||
uint32_t m_width;
|
uint32_t m_width[16];
|
||||||
uint32_t m_height;
|
uint32_t m_height[16];
|
||||||
uint32_t m_white[16*16];
|
uint32_t m_white[16*16];
|
||||||
enum : uint16_t { CACHE_SIZE = 1024 };
|
enum : uint16_t { CACHE_SIZE = 1024 };
|
||||||
enum : uint32_t { PACKABLE_SIZE = 128 };
|
enum : uint32_t { PACKABLE_SIZE = 128 };
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
// TYPE DEFINITIONS
|
// TYPE DEFINITIONS
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
class vertex;
|
struct vertex;
|
||||||
class texture_info;
|
class texture_info;
|
||||||
class texture_manager;
|
class texture_manager;
|
||||||
class device;
|
struct device;
|
||||||
class vertex_buffer;
|
struct vertex_buffer;
|
||||||
class shaders;
|
class shaders;
|
||||||
class hlsl_options;
|
struct hlsl_options;
|
||||||
class poly_info;
|
class poly_info;
|
||||||
|
|
||||||
/* renderer is the information about Direct3D for the current screen */
|
/* renderer is the information about Direct3D for the current screen */
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
// ======================> osd_interface
|
// ======================> osd_interface
|
||||||
|
|
||||||
class slider_state;
|
struct slider_state;
|
||||||
|
|
||||||
// description of the currently-running machine
|
// description of the currently-running machine
|
||||||
class osd_interface
|
class osd_interface
|
||||||
|
Loading…
Reference in New Issue
Block a user