Previous 199869 Revisions Next

r45067 Sunday 21st February, 2016 at 02:03:28 UTC by Ryan Holtz
More work on targets, nw
[src/osd]osdepend.h
[src/osd/modules/render]drawbgfx.cpp drawbgfx.h drawd3d.h
[src/osd/modules/render/bgfx]effectreader.cpp target.cpp target.h targetmanager.cpp targetmanager.h

trunk/src/osd/modules/render/bgfx/effectreader.cpp
r253578r253579
6464    {
6565       assert(value["pixel"].IsString());
6666   }
67    assert(value.HasMember("uniform"));
68    assert(value["uniform"].IsArray());
67    assert(value.HasMember("uniforms"));
68    assert(value["uniforms"].IsArray());
6969}
No newline at end of file
trunk/src/osd/modules/render/bgfx/target.cpp
r253578r253579
66   m_target = bgfx::createFrameBuffer(1, &m_handle, false);
77}
88
9bgfx_target::bgfx_target(std::string name, void *handle, uint32_t width, uint32_t height)
10   : 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)
11{
12   m_target = bgfx::createFrameBuffer(handle, width, height);
13}
14
915bgfx_target::~bgfx_target()
1016{
1117   bgfx::destroyFrameBuffer(m_target);
trunk/src/osd/modules/render/bgfx/target.h
r253578r253579
99{
1010public:
1111    bgfx_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, bool filter = false);
12    bgfx_target(std::string name, void *handle, uint32_t width, uint32_t height);
1213    virtual ~bgfx_target();
1314
1415    // Getters
trunk/src/osd/modules/render/bgfx/targetmanager.cpp
r253578r253579
1414
1515bgfx_target* target_manager::create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, bool filter)
1616{
17   printf("Creating %s\n", name.c_str());
1718   bgfx_target* target = new bgfx_target(name, format, width, height, filter);
1819   m_targets[name] = target;
1920
r253578r253579
2122   return target;
2223}
2324
25bgfx_target* target_manager::create_target(std::string name, void *handle, uint32_t width, uint32_t height)
26{
27   printf("Creating %s\n", name.c_str());
28   bgfx_target* target = new bgfx_target(name, handle, width, height);
29   m_targets[name] = target;
30
31   m_textures.add_texture(name, target);
32   return target;
33}
34
2435bgfx_target* target_manager::target(std::string name)
2536{
2637    std::map<std::string, bgfx_target*>::iterator iter = m_targets.find(name);
trunk/src/osd/modules/render/bgfx/targetmanager.h
r253578r253579
1818    ~target_manager();
1919
2020   bgfx_target* create_target(std::string name, bgfx::TextureFormat::Enum format, uint32_t width, uint32_t height, bool filter = false);
21   bgfx_target* create_target(std::string name, void *handle, uint32_t width, uint32_t height);
2122
2223    // Getters
2324    bgfx_target* target(std::string name);
trunk/src/osd/modules/render/drawbgfx.cpp
r253578r253579
3232
3333#include "drawbgfx.h"
3434#include "bgfx/texturemanager.h"
35#include "bgfx/targetmanager.h"
3536#include "bgfx/shadermanager.h"
3637#include "bgfx/effectmanager.h"
3738#include "bgfx/effect.h"
3839#include "bgfx/texture.h"
40#include "bgfx/target.h"
3941
4042//============================================================
4143//  DEBUGGING
r253578r253579
9496   // create renderer
9597
9698   osd_dim wdim = window().get_size();
97   m_width = wdim.width();
98   m_height = wdim.height();
99   m_width[window().m_index] = wdim.width();
100   m_height[window().m_index] = wdim.height();
99101   if (window().m_index == 0)
100102   {
101103#ifdef OSD_WINDOWS
r253578r253579
104106      bgfx::sdlSetWindow(window().sdl_window());
105107#endif
106108      bgfx::init();
107      bgfx::reset(m_width, m_height, video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
109      bgfx::reset(m_width[window().m_index], m_height[window().m_index], video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
108110      // Enable debug text.
109111      bgfx::setDebug(BGFX_DEBUG_TEXT); //BGFX_DEBUG_STATS
110      m_dimensions = osd_dim(m_width, m_height);
112      m_dimensions = osd_dim(m_width[0], m_height[0]);
113
114      ScreenVertex::init();
111115   }
112   else
113   {
114#ifdef OSD_WINDOWS
115      m_framebuffer = bgfx::createFrameBuffer(window().m_hwnd, m_width, m_height);
116#else
117      m_framebuffer = bgfx::createFrameBuffer(sdlNativeWindowHandle(window().sdl_window()), m_width, m_height);
118#endif
119      bgfx::touch(window().m_index);
120   }
121116
122   ScreenVertex::init();
123
124117   m_textures = new texture_manager();
118   m_targets = new target_manager(*m_textures);
125119   m_shaders = new shader_manager();
126120   m_effects = new effect_manager(*m_shaders);
127121
122    if (window().m_index != 0)
123    {
124#ifdef OSD_WINDOWS
125       m_framebuffer = m_targets->create_target("backbuffer", window().m_hwnd, m_width[window().m_index], m_height[window().m_index]);
126#else
127       m_framebuffer = m_targets->create_target("backbuffer", sdlNativeWindowHandle(window().sdl_window()), m_width[window().m_index], m_height[window().m_index]);
128#endif
129       bgfx::touch(window().m_index);
130    }
131
128132   // Create program from shaders.
129   printf("1\n"); fflush(stdout);
130133   m_gui_effect[0] = m_effects->effect("gui_opaque");
131   printf("2\n"); fflush(stdout);
132134   m_gui_effect[1] = m_effects->effect("gui_blend");
133   printf("3\n"); fflush(stdout);
134135   m_gui_effect[2] = m_effects->effect("gui_multiply");
135   printf("4\n"); fflush(stdout);
136136   m_gui_effect[3] = m_effects->effect("gui_add");
137   printf("5\n"); fflush(stdout);
138137
139138   m_screen_effect[0] = m_effects->effect("screen_opaque");
140   printf("6\n"); fflush(stdout);
141139   m_screen_effect[1] = m_effects->effect("screen_blend");
142   printf("7\n"); fflush(stdout);
143140   m_screen_effect[2] = m_effects->effect("screen_multiply");
144   printf("8\n"); fflush(stdout);
145141   m_screen_effect[3] = m_effects->effect("screen_add");
146   printf("9\n"); fflush(stdout);
147142
148143   uint32_t flags = BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT;
149144   m_texture_cache = m_textures->create_texture("#cache", bgfx::TextureFormat::RGBA8, CACHE_SIZE, CACHE_SIZE, nullptr, flags);
r253578r253579
160155
161156renderer_bgfx::~renderer_bgfx()
162157{
163   if (window().m_index > 0)
164   {
165      bgfx::destroyFrameBuffer(m_framebuffer);
166   }
167
168158   // Cleanup.
159   delete m_targets;
160   delete m_textures;
169161   delete m_effects;
170162   delete m_shaders;
171   delete m_textures;
172163
173164   bgfx::shutdown();
174165}
r253578r253579
741732   int index = window().m_index;
742733   // Set view 0 default viewport.
743734   osd_dim wdim = window().get_size();
744   int width = wdim.width();
745   int height = wdim.height();
735   m_width[index] = wdim.width();
736   m_height[index] = wdim.height();
746737   if (index == 0)
747738   {
748      if ((m_dimensions != osd_dim(width, height)))
739      if ((m_dimensions != osd_dim(m_width[index], m_height[index])))
749740      {
750         bgfx::reset(width, height, video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
751         m_dimensions = osd_dim(width, height);
741         bgfx::reset(m_width[index], m_height[index], video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
742         m_dimensions = osd_dim(m_width[index], m_height[index]);
752743      }
753744   }
754745   else
755746   {
756      if ((m_dimensions != osd_dim(width, height)))
747      if ((m_dimensions != osd_dim(m_width[index], m_height[index])))
757748      {
758749         bgfx::reset(window().m_main->get_size().width(), window().m_main->get_size().height(), video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
759         if (bgfx::isValid(m_framebuffer))
760         {
761            bgfx::destroyFrameBuffer(m_framebuffer);
762         }
750         delete m_framebuffer;
763751#ifdef OSD_WINDOWS
764         m_framebuffer = bgfx::createFrameBuffer(window().m_hwnd, width, height);
752         m_framebuffer = m_targets->create_target("backbuffer", window().m_hwnd, m_width[index], m_height[index]);
765753#else
766         m_framebuffer = bgfx::createFrameBuffer(sdlNativeWindowHandle(window().sdl_window()), width, height);
754         m_framebuffer = m_targets->create_target("backbuffer", sdlNativeWindowHandle(window().sdl_window()), m_width[index], m_height[index]);
767755#endif
768         bgfx::setViewFrameBuffer(index, m_framebuffer);
769         m_dimensions = osd_dim(width, height);
756         bgfx::setViewFrameBuffer(index, m_framebuffer->target());
757         m_dimensions = osd_dim(m_width[index], m_height[index]);
770758         bgfx::setViewClear(index
771759            , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
772760            , 0x000000ff
r253578r253579
779767      }
780768   }
781769
782   if (index != 0)
783   {
784      bgfx::setViewFrameBuffer(index, m_framebuffer);
785   }
786   bgfx::setViewSeq(index, true);
787   bgfx::setViewRect(index, 0, 0, width, height);
770    if (index != 0)
771    {
772        bgfx::setViewFrameBuffer(index, m_framebuffer->target());
773    }
774       bgfx::setViewSeq(index, true);
775   bgfx::setViewRect(index, 0, 0, m_width[index], m_height[index]);
788776
789777   // Setup view transform.
790778   {
r253578r253579
793781
794782      float left = 0.0f;
795783      float top = 0.0f;
796      float right = width;
797      float bottom = height;
784      float right = m_width[index];
785      float bottom = m_height[index];
798786      float proj[16];
799787      bx::mtxOrtho(proj, left, right, bottom, top, 0.0f, 100.0f);
800788      bgfx::setViewTransform(index, view, proj);
r253578r253579
806794      , 0
807795      );
808796
809   // This dummy draw call is here to make sure that view 0 is cleared
810   // if no other draw calls are submitted to view 0.
811   bgfx::touch(index);
812
813797   window().m_primlist->acquire_lock();
814798
815799   // Mark our texture atlas as dirty if we need to do so
r253578r253579
839823   }
840824
841825   window().m_primlist->release_lock();
826
827   // This dummy draw call is here to make sure that view 0 is cleared
828   // if no other draw calls are submitted to view 0.
829   bgfx::touch(index);
830
842831   // Advance to next frame. Rendering thread will be kicked to
843832   // process submitted rendering primitives.
844833   if (index==0) bgfx::frame();
trunk/src/osd/modules/render/drawbgfx.h
r253578r253579
1111#include "binpacker.h"
1212
1313class texture_manager;
14class target_manager;
1415class shader_manager;
1516class effect_manager;
1617class bgfx_texture;
1718class bgfx_effect;
19class bgfx_target;
1820
1921/* sdl_info is the information about SDL for the current screen */
2022class renderer_bgfx : public osd_renderer
r253578r253579
9395   const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(UINT32 format, int width, int height, int rowpixels, const rgb_t *palette, void *base);
9496   UINT32 get_texture_hash(render_primitive *prim);
9597
96   bgfx::FrameBufferHandle m_framebuffer;
98   bgfx_target* m_framebuffer;
9799   bgfx_texture* m_texture_cache;
98100
99101   // Original display_mode
100102   osd_dim m_dimensions;
101103
102104   texture_manager* m_textures;
105   target_manager* m_targets;
103106   shader_manager* m_shaders;
104107   effect_manager* m_effects;
105108   bgfx_effect* m_gui_effect[4];
r253578r253579
109112   std::vector<rectangle_packer::packable_rectangle> m_texinfo;
110113   rectangle_packer m_packer;
111114
112   uint32_t m_width;
113   uint32_t m_height;
115   uint32_t m_width[16];
116   uint32_t m_height[16];
114117   uint32_t m_white[16*16];
115118   enum : uint16_t { CACHE_SIZE = 1024 };
116119   enum : uint32_t { PACKABLE_SIZE = 128 };
trunk/src/osd/modules/render/drawd3d.h
r253578r253579
2525//  TYPE DEFINITIONS
2626//============================================================
2727
28class vertex;
28struct vertex;
2929class texture_info;
3030class texture_manager;
31class device;
32class vertex_buffer;
31struct device;
32struct vertex_buffer;
3333class shaders;
34class hlsl_options;
34struct hlsl_options;
3535class poly_info;
3636
3737/* renderer is the information about Direct3D for the current screen */
trunk/src/osd/osdepend.h
r253578r253579
4141
4242// ======================> osd_interface
4343
44class slider_state;
44struct slider_state;
4545
4646// description of the currently-running machine
4747class osd_interface


Previous 199869 Revisions Next


© 1997-2024 The MAME Team