From 2d9e6e7f4f67496aacf611d4cfc0faf864d331ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Thu, 14 Oct 2021 21:03:26 -0700 Subject: [PATCH] Added setTexture validation to check for read back texture. --- src/bgfx.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 1cd156603..7df640e1d 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -3822,6 +3822,13 @@ namespace bgfx BGFX_CHECK_HANDLE("setTexture/UniformHandle", s_ctx->m_uniformHandle, _sampler); BGFX_CHECK_HANDLE_INVALID_OK("setTexture/TextureHandle", s_ctx->m_textureHandle, _handle); BX_ASSERT(_stage < g_caps.limits.maxTextureSamplers, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxTextureSamplers); + + const TextureRef& ref = s_ctx->m_textureRef[_handle.idx]; + BX_ASSERT(!ref.isReadBack() + , "Can't sample from texture which was created with BGFX_TEXTURE_READ_BACK. This is CPU only texture." + ); + BX_UNUSED(ref); + BGFX_ENCODER(setTexture(_stage, _sampler, _handle, _flags) ); }