Refactored KRTexture::resize for Vulkan.

This commit is contained in:
2022-07-14 00:00:55 -07:00
parent 1d11be0e61
commit b857654cf6
2 changed files with 5 additions and 8 deletions

View File

@@ -98,14 +98,12 @@ void KRTexture::resize(int max_dim)
{ {
while(m_handle_lock.test_and_set()) {}; // Spin lock while(m_handle_lock.test_and_set()) {}; // Spin lock
if(m_iHandle == m_iNewHandle) { if(!m_haveNewHandles) {
if(max_dim == 0) { if(max_dim > 0) {
m_iNewHandle = 0;
} else {
int target_dim = max_dim; int target_dim = max_dim;
if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim; if(target_dim < (int)m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
if(m_new_lod_max_dim != target_dim || (m_iHandle == 0 && m_iNewHandle == 0)) { if(m_new_lod_max_dim != target_dim || m_handles.empty()) {
assert(m_newTextureMemUsed == 0); assert(m_newTextureMemUsed == 0);
m_newTextureMemUsed = getMemRequiredForSize(target_dim); m_newTextureMemUsed = getMemRequiredForSize(target_dim);

View File

@@ -42,14 +42,13 @@ KRTexture2D::~KRTexture2D() {
} }
bool KRTexture2D::createGLTexture(int lod_max_dim) { bool KRTexture2D::createGLTexture(int lod_max_dim) {
if(m_iHandle != m_iNewHandle) { if (m_haveNewHandles) {
return true; return true;
} }
bool success = true; bool success = true;
int prev_lod_max_dim = m_new_lod_max_dim; int prev_lod_max_dim = m_new_lod_max_dim;
m_iNewHandle = 0; m_iNewHandle = 0;
m_new_lod_max_dim = 0; m_new_lod_max_dim = 0;
GLDEBUG(glGenTextures(1, &m_iNewHandle)); GLDEBUG(glGenTextures(1, &m_iNewHandle));