vbo_type::TEMPORARY changed to vbo_type::IMMEDIATE.
KRMeshManager no longer allocates, owns, and deletes IMMEDIATE/TEMPORARY data. Added KRCamera::m_debug_text_vertices, and KRCamera::m_debug_text_vbo_data in preparation for further work on immediately loaded mesh data.
This commit is contained in:
@@ -62,6 +62,12 @@ KRCamera::KRCamera(KRScene &scene, std::string name) : KRNode(scene, name) {
|
||||
m_downsample = Vector2::One();
|
||||
|
||||
m_fade_color = Vector4::Zero();
|
||||
|
||||
m_debug_text_vbo_data.init(m_pContext->getMeshManager(), m_debug_text_vertices, m_debug_text_indices, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true, KRMeshManager::KRVBOData::IMMEDIATE
|
||||
#if KRENGINE_DEBUG_GPU_LABELS
|
||||
, "Debug Text"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
KRCamera::~KRCamera() {
|
||||
@@ -728,15 +734,10 @@ void KRCamera::renderPost(VkCommandBuffer& commandBuffer, KRSurface& surface)
|
||||
|
||||
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
|
||||
|
||||
KRDataBlock index_data;
|
||||
m_pContext->getMeshManager()->bindVBO(commandBuffer, m_debug_text_vertices, index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true, 1.0f
|
||||
|
||||
#if KRENGINE_DEBUG_GPU_LABELS
|
||||
, "Debug Text"
|
||||
#endif
|
||||
);
|
||||
m_debug_text_vbo_data.load(commandBuffer);
|
||||
m_debug_text_vbo_data.bind(commandBuffer);
|
||||
|
||||
vkCmdDraw(commandBuffer, vertex_count, 1, 0, 0);
|
||||
// vkCmdDraw(commandBuffer, vertex_count, 1, 0, 0);
|
||||
|
||||
m_debug_text_vertices.unlock();
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "KRContext.h"
|
||||
#include "KRViewport.h"
|
||||
#include "KRRenderSettings.h"
|
||||
#include "KRMeshManager.h"
|
||||
|
||||
#define KRAKEN_FPS_AVERAGE_FRAME_COUNT 30
|
||||
|
||||
@@ -110,6 +111,8 @@ private:
|
||||
} DebugTextVertexData;
|
||||
|
||||
KRDataBlock m_debug_text_vertices;
|
||||
KRDataBlock m_debug_text_indices;
|
||||
KRMeshManager::KRVBOData m_debug_text_vbo_data;
|
||||
|
||||
// std::string getDebugText();
|
||||
|
||||
|
||||
@@ -197,14 +197,11 @@ void KRMeshManager::bindVBO(VkCommandBuffer& commandBuffer, KRVBOData *vbo_data,
|
||||
vbo_changed = true;
|
||||
}
|
||||
|
||||
bool used_vbo_data = false;
|
||||
|
||||
if(vbo_changed) {
|
||||
|
||||
if(m_vbosActive.find(vbo_data->m_data) != m_vbosActive.end()) {
|
||||
m_currentVBO = m_vbosActive[vbo_data->m_data];
|
||||
} else {
|
||||
used_vbo_data = true;
|
||||
m_currentVBO = vbo_data;
|
||||
|
||||
m_vbosActive[vbo_data->m_data] = m_currentVBO;
|
||||
@@ -212,10 +209,6 @@ void KRMeshManager::bindVBO(VkCommandBuffer& commandBuffer, KRVBOData *vbo_data,
|
||||
|
||||
m_currentVBO->bind(commandBuffer);
|
||||
}
|
||||
|
||||
if(!used_vbo_data && vbo_data->getType() == KRVBOData::TEMPORARY) {
|
||||
delete vbo_data;
|
||||
}
|
||||
}
|
||||
|
||||
void KRMeshManager::startFrame(float deltaTime)
|
||||
@@ -249,11 +242,9 @@ void KRMeshManager::startFrame(float deltaTime)
|
||||
|
||||
switch(activeVBO->getType()) {
|
||||
case KRVBOData::STREAMING:
|
||||
case KRVBOData::IMMEDIATE:
|
||||
activeVBO->unload();
|
||||
break;
|
||||
case KRVBOData::TEMPORARY:
|
||||
delete activeVBO;
|
||||
break;
|
||||
case KRVBOData::CONSTANT:
|
||||
// CONSTANT VBO's are not unloaded
|
||||
break;
|
||||
@@ -325,7 +316,8 @@ void KRMeshManager::bindVBO(VkCommandBuffer& commandBuffer, KRDataBlock &data, K
|
||||
#endif
|
||||
)
|
||||
{
|
||||
KRVBOData *vbo_data = new KRVBOData(this, data, index_data, vertex_attrib_flags, static_vbo, KRVBOData::TEMPORARY
|
||||
// TODO - Vulkan refactoring... This will leak.. Update all call sites to own their own KRVBOData and then remove this function
|
||||
KRVBOData *vbo_data = new KRVBOData(this, data, index_data, vertex_attrib_flags, static_vbo, KRVBOData::IMMEDIATE
|
||||
#if KRENGINE_DEBUG_GPU_LABELS
|
||||
, debug_label
|
||||
#endif
|
||||
@@ -564,8 +556,8 @@ void KRMeshManager::KRVBOData::load(VkCommandBuffer& commandBuffer)
|
||||
case vbo_type::CONSTANT:
|
||||
type_label = "Constant";
|
||||
break;
|
||||
case vbo_type::TEMPORARY:
|
||||
type_label = "Temporary";
|
||||
case vbo_type::IMMEDIATE:
|
||||
type_label = "Immediate";
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
@@ -584,14 +576,14 @@ void KRMeshManager::KRVBOData::load(VkCommandBuffer& commandBuffer)
|
||||
, debug_label
|
||||
#endif // KRENGINE_DEBUG_GPU_LABELS
|
||||
);
|
||||
if (m_type == vbo_type::TEMPORARY) {
|
||||
if (m_type == vbo_type::IMMEDIATE) {
|
||||
device.graphicsUpload(commandBuffer, *m_data, allocation.vertex_buffer);
|
||||
} else {
|
||||
device.streamUpload(*m_data, allocation.vertex_buffer);
|
||||
}
|
||||
|
||||
|
||||
if (m_index_data->getSize() > 0) {
|
||||
if (m_index_data && m_index_data->getSize() > 0) {
|
||||
#if KRENGINE_DEBUG_GPU_LABELS
|
||||
snprintf(debug_label, KRENGINE_DEBUG_GPU_LABEL_MAX_LEN, "%s Indexes: %s", type_label, m_debugLabel);
|
||||
#endif // KRENGINE_DEBUG_GPU_LABELS
|
||||
@@ -605,7 +597,7 @@ void KRMeshManager::KRVBOData::load(VkCommandBuffer& commandBuffer)
|
||||
, debug_label
|
||||
#endif
|
||||
);
|
||||
if (m_type == vbo_type::TEMPORARY) {
|
||||
if (m_type == vbo_type::IMMEDIATE) {
|
||||
device.graphicsUpload(commandBuffer, *m_index_data, allocation.index_buffer);
|
||||
} else {
|
||||
device.streamUpload(*m_index_data, allocation.index_buffer);
|
||||
|
||||
@@ -70,8 +70,14 @@ public:
|
||||
|
||||
typedef enum {
|
||||
STREAMING,
|
||||
// STREAMING data is loaded asynchronously, with transfer queues in the streamer thread.
|
||||
|
||||
CONSTANT,
|
||||
TEMPORARY
|
||||
// CONSTANT data is loaded asyncrhronously, with transfer queues in the streamer thread, but is not unloaded.
|
||||
|
||||
IMMEDIATE
|
||||
// IMMEDIATE data is loaded synchronously, with graphics queues in the presentation threads.
|
||||
// IMMEDIATE data is available for use immediately on the same frame it is generated.
|
||||
} vbo_type;
|
||||
|
||||
KRVBOData();
|
||||
|
||||
Reference in New Issue
Block a user