Added setTexture validation to check for read back texture.

This commit is contained in:
Бранимир Караџић 2021-10-14 21:03:26 -07:00
parent 46384208ad
commit 2d9e6e7f4f

View File

@ -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) );
}