remove async task from texture and sampler binding, but add render thread assert

This commit is contained in:
2019-07-28 11:16:20 +02:00
parent 627a3bbb14
commit b6b0fb74f9
2 changed files with 13 additions and 9 deletions

View File

@@ -222,6 +222,7 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format,
void RTT::bindFramebuffer() void RTT::bindFramebuffer()
{ {
assert(App::I->is_render_thread());
#ifdef _DEBUG #ifdef _DEBUG
if (bound) if (bound)
{ {
@@ -240,6 +241,7 @@ void RTT::bindFramebuffer()
void RTT::unbindFramebuffer() void RTT::unbindFramebuffer()
{ {
assert(App::I->is_render_thread());
if (!bound) if (!bound)
return; return;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDFboID); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDFboID);
@@ -251,12 +253,14 @@ void RTT::unbindFramebuffer()
void RTT::clear(glm::vec4 color) void RTT::clear(glm::vec4 color)
{ {
assert(App::I->is_render_thread());
glClearColor(color.r, color.g, color.b, color.a); glClearColor(color.r, color.g, color.b, color.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
} }
void RTT::clear_mask(glm::bool4 mask, glm::vec4 color) void RTT::clear_mask(glm::bool4 mask, glm::vec4 color)
{ {
assert(App::I->is_render_thread());
// save old state // save old state
std::array<GLboolean, 4> old_mask; std::array<GLboolean, 4> old_mask;
glGetBooleanv(GL_COLOR_WRITEMASK, old_mask.data()); glGetBooleanv(GL_COLOR_WRITEMASK, old_mask.data());
@@ -331,11 +335,13 @@ float * RTT::createBufferFloat()
void RTT::bindTexture() void RTT::bindTexture()
{ {
assert(App::I->is_render_thread());
glBindTexture(GL_TEXTURE_2D, texID); glBindTexture(GL_TEXTURE_2D, texID);
} }
void RTT::unbindTexture() void RTT::unbindTexture()
{ {
assert(App::I->is_render_thread());
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }

View File

@@ -118,11 +118,13 @@ void Texture2D::destroy()
void Texture2D::bind() const void Texture2D::bind() const
{ {
assert(App::I->is_render_thread());
glBindTexture(GL_TEXTURE_2D, m_tex); glBindTexture(GL_TEXTURE_2D, m_tex);
} }
void Texture2D::unbind() const void Texture2D::unbind() const
{ {
assert(App::I->is_render_thread());
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }
@@ -201,21 +203,17 @@ void Sampler::set_border(glm::vec4 rgba)
} }
void Sampler::bind(int unit) const void Sampler::bind(int unit) const
{ {
App::I->render_task([=] assert(App::I->is_render_thread());
{ current_unit = unit;
current_unit = unit;
#if USE_SAMPLER #if USE_SAMPLER
glBindSampler(unit, id); glBindSampler(unit, id);
#endif // USE_SAMPLER #endif // USE_SAMPLER
});
} }
void Sampler::unbind() void Sampler::unbind()
{ {
App::I->render_task([=] assert(App::I->is_render_thread());
{
#if USE_SAMPLER #if USE_SAMPLER
glBindSampler(current_unit, 0); glBindSampler(current_unit, 0);
#endif // USE_SAMPLER #endif // USE_SAMPLER
});
} }