diff options
author | 2016-03-23 17:55:55 +0100 | |
---|---|---|
committer | 2016-03-23 17:55:55 +0100 | |
commit | ba0a1d8d5218804bc1d5b09d5b3fa8fcd537f0bf (patch) | |
tree | 9fe5ca6f9f6352f724ea9a26fff5ebda23576607 /src/osd/modules/render/bgfx/inputpair.cpp | |
parent | d0867ac3f2bdcfd4d1d2361ce8b6408a185908f4 (diff) | |
parent | 5ed9f938ea322d386e949d2752892651d9ee9fde (diff) |
Merge bgfx_shader into master, nw
Diffstat (limited to 'src/osd/modules/render/bgfx/inputpair.cpp')
-rw-r--r-- | src/osd/modules/render/bgfx/inputpair.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/osd/modules/render/bgfx/inputpair.cpp b/src/osd/modules/render/bgfx/inputpair.cpp index e28372db3ce..8603f7caa5e 100644 --- a/src/osd/modules/render/bgfx/inputpair.cpp +++ b/src/osd/modules/render/bgfx/inputpair.cpp @@ -9,18 +9,39 @@ // //============================================================ +#include "emu.h" + #include "inputpair.h" #include "texture.h" +#include "target.h" #include "effect.h" +#include "uniform.h" +#include "texturemanager.h" +#include "targetmanager.h" -bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, bgfx_texture* texture) +bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, std::string texture) : m_index(index) , m_sampler(sampler) , m_texture(texture) { } -void bgfx_input_pair::bind(bgfx_effect *effect) +void bgfx_input_pair::bind(bgfx_effect *effect, target_manager& targets, texture_manager& textures, const int32_t screen) const { - bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), m_texture->handle()); + assert(effect->uniform(m_sampler) != nullptr); + std::string name = m_texture; + if (targets.target(m_texture + std::to_string(screen)) != nullptr) + { + name = m_texture + std::to_string(screen); + } + + bgfx_texture_handle_provider* provider = textures.provider(name); + bgfx_uniform *tex_size = effect->uniform("u_tex_size" + std::to_string(m_index)); + if (tex_size != nullptr) + { + float values[2] = { float(provider->width()), float(provider->height()) }; + tex_size->set(values, sizeof(float) * 2); + } + + bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), textures.handle(name)); } |