Beginning refactoring of KRTexture for Vulkan. Added KRTexture::TextureHandle.
This commit is contained in:
@@ -587,6 +587,9 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
|||||||
// GLDEBUG(glBindTexture(GL_TEXTURE_2D, 0));
|
// GLDEBUG(glBindTexture(GL_TEXTURE_2D, 0));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// TODO - Test code for Vulkan conversion, remove once texture streaming working
|
||||||
|
// m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
|
||||||
|
|
||||||
const char *szText = settings.m_debug_text.c_str();
|
const char *szText = settings.m_debug_text.c_str();
|
||||||
|
|
||||||
std::string debug_text;
|
std::string debug_text;
|
||||||
|
|||||||
@@ -56,19 +56,26 @@ KRTexture::~KRTexture()
|
|||||||
|
|
||||||
void KRTexture::releaseHandles() {
|
void KRTexture::releaseHandles() {
|
||||||
long mem_size = getMemSize();
|
long mem_size = getMemSize();
|
||||||
|
KRDeviceManager* deviceManager = getContext().getDeviceManager();
|
||||||
|
|
||||||
while(m_handle_lock.test_and_set()); // Spin lock
|
while(m_handle_lock.test_and_set()); // Spin lock
|
||||||
|
|
||||||
if(m_iNewHandle != 0) {
|
for (TextureHandle t : m_newHandles) {
|
||||||
GLDEBUG(glDeleteTextures(1, &m_iNewHandle));
|
std::unique_ptr<KRDevice>& device = deviceManager->getDevice(t.device);
|
||||||
m_iNewHandle = 0;
|
VmaAllocator allocator = device->getAllocator();
|
||||||
m_newTextureMemUsed = 0;
|
vmaDestroyImage(allocator, t.image, t.allocation);
|
||||||
}
|
}
|
||||||
if(m_iHandle != 0) {
|
m_newHandles.clear();
|
||||||
GLDEBUG(glDeleteTextures(1, &m_iHandle));
|
m_newTextureMemUsed = 0;
|
||||||
m_iHandle = 0;
|
|
||||||
m_textureMemUsed = 0;
|
for (TextureHandle t : m_handles) {
|
||||||
|
std::unique_ptr<KRDevice>& device = deviceManager->getDevice(t.device);
|
||||||
|
VmaAllocator allocator = device->getAllocator();
|
||||||
|
vmaDestroyImage(allocator, t.image, t.allocation);
|
||||||
}
|
}
|
||||||
|
m_handles.clear();
|
||||||
|
m_textureMemUsed = 0;
|
||||||
|
|
||||||
m_current_lod_max_dim = 0;
|
m_current_lod_max_dim = 0;
|
||||||
m_new_lod_max_dim = 0;
|
m_new_lod_max_dim = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,16 @@ protected:
|
|||||||
virtual bool createGLTexture(int lod_max_dim) = 0;
|
virtual bool createGLTexture(int lod_max_dim) = 0;
|
||||||
GLuint getHandle();
|
GLuint getHandle();
|
||||||
|
|
||||||
|
struct TextureHandle {
|
||||||
|
VkImage image;
|
||||||
|
KrDeviceHandle device;
|
||||||
|
VmaAllocation allocation;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<TextureHandle> m_handles;
|
||||||
|
std::vector<TextureHandle> m_newHandles;
|
||||||
|
|
||||||
|
// TODO - Remove m_iHandle and m_iNewHandle once Vulkan refactoring complete
|
||||||
GLuint m_iHandle;
|
GLuint m_iHandle;
|
||||||
GLuint m_iNewHandle;
|
GLuint m_iNewHandle;
|
||||||
std::atomic_flag m_handle_lock;
|
std::atomic_flag m_handle_lock;
|
||||||
|
|||||||
@@ -82,7 +82,10 @@ void KRTextureManager::_setActiveTexture(int i)
|
|||||||
{
|
{
|
||||||
if(m_iActiveTexture != i) {
|
if(m_iActiveTexture != i) {
|
||||||
m_iActiveTexture = i;
|
m_iActiveTexture = i;
|
||||||
|
/*
|
||||||
|
// TODO - Vulkan refactoring
|
||||||
GLDEBUG(glActiveTexture(GL_TEXTURE0 + i));
|
GLDEBUG(glActiveTexture(GL_TEXTURE0 + i));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user