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_downsample = Vector2::One();
|
||||||
|
|
||||||
m_fade_color = Vector4::Zero();
|
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() {
|
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);
|
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
|
||||||
|
|
||||||
KRDataBlock index_data;
|
m_debug_text_vbo_data.load(commandBuffer);
|
||||||
m_pContext->getMeshManager()->bindVBO(commandBuffer, m_debug_text_vertices, index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true, 1.0f
|
m_debug_text_vbo_data.bind(commandBuffer);
|
||||||
|
|
||||||
#if KRENGINE_DEBUG_GPU_LABELS
|
// vkCmdDraw(commandBuffer, vertex_count, 1, 0, 0);
|
||||||
, "Debug Text"
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
vkCmdDraw(commandBuffer, vertex_count, 1, 0, 0);
|
|
||||||
|
|
||||||
m_debug_text_vertices.unlock();
|
m_debug_text_vertices.unlock();
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "KRContext.h"
|
#include "KRContext.h"
|
||||||
#include "KRViewport.h"
|
#include "KRViewport.h"
|
||||||
#include "KRRenderSettings.h"
|
#include "KRRenderSettings.h"
|
||||||
|
#include "KRMeshManager.h"
|
||||||
|
|
||||||
#define KRAKEN_FPS_AVERAGE_FRAME_COUNT 30
|
#define KRAKEN_FPS_AVERAGE_FRAME_COUNT 30
|
||||||
|
|
||||||
@@ -110,6 +111,8 @@ private:
|
|||||||
} DebugTextVertexData;
|
} DebugTextVertexData;
|
||||||
|
|
||||||
KRDataBlock m_debug_text_vertices;
|
KRDataBlock m_debug_text_vertices;
|
||||||
|
KRDataBlock m_debug_text_indices;
|
||||||
|
KRMeshManager::KRVBOData m_debug_text_vbo_data;
|
||||||
|
|
||||||
// std::string getDebugText();
|
// std::string getDebugText();
|
||||||
|
|
||||||
|
|||||||
@@ -197,14 +197,11 @@ void KRMeshManager::bindVBO(VkCommandBuffer& commandBuffer, KRVBOData *vbo_data,
|
|||||||
vbo_changed = true;
|
vbo_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool used_vbo_data = false;
|
|
||||||
|
|
||||||
if(vbo_changed) {
|
if(vbo_changed) {
|
||||||
|
|
||||||
if(m_vbosActive.find(vbo_data->m_data) != m_vbosActive.end()) {
|
if(m_vbosActive.find(vbo_data->m_data) != m_vbosActive.end()) {
|
||||||
m_currentVBO = m_vbosActive[vbo_data->m_data];
|
m_currentVBO = m_vbosActive[vbo_data->m_data];
|
||||||
} else {
|
} else {
|
||||||
used_vbo_data = true;
|
|
||||||
m_currentVBO = vbo_data;
|
m_currentVBO = vbo_data;
|
||||||
|
|
||||||
m_vbosActive[vbo_data->m_data] = m_currentVBO;
|
m_vbosActive[vbo_data->m_data] = m_currentVBO;
|
||||||
@@ -212,10 +209,6 @@ void KRMeshManager::bindVBO(VkCommandBuffer& commandBuffer, KRVBOData *vbo_data,
|
|||||||
|
|
||||||
m_currentVBO->bind(commandBuffer);
|
m_currentVBO->bind(commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!used_vbo_data && vbo_data->getType() == KRVBOData::TEMPORARY) {
|
|
||||||
delete vbo_data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMeshManager::startFrame(float deltaTime)
|
void KRMeshManager::startFrame(float deltaTime)
|
||||||
@@ -249,11 +242,9 @@ void KRMeshManager::startFrame(float deltaTime)
|
|||||||
|
|
||||||
switch(activeVBO->getType()) {
|
switch(activeVBO->getType()) {
|
||||||
case KRVBOData::STREAMING:
|
case KRVBOData::STREAMING:
|
||||||
|
case KRVBOData::IMMEDIATE:
|
||||||
activeVBO->unload();
|
activeVBO->unload();
|
||||||
break;
|
break;
|
||||||
case KRVBOData::TEMPORARY:
|
|
||||||
delete activeVBO;
|
|
||||||
break;
|
|
||||||
case KRVBOData::CONSTANT:
|
case KRVBOData::CONSTANT:
|
||||||
// CONSTANT VBO's are not unloaded
|
// CONSTANT VBO's are not unloaded
|
||||||
break;
|
break;
|
||||||
@@ -325,7 +316,8 @@ void KRMeshManager::bindVBO(VkCommandBuffer& commandBuffer, KRDataBlock &data, K
|
|||||||
#endif
|
#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
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
, debug_label
|
, debug_label
|
||||||
#endif
|
#endif
|
||||||
@@ -564,8 +556,8 @@ void KRMeshManager::KRVBOData::load(VkCommandBuffer& commandBuffer)
|
|||||||
case vbo_type::CONSTANT:
|
case vbo_type::CONSTANT:
|
||||||
type_label = "Constant";
|
type_label = "Constant";
|
||||||
break;
|
break;
|
||||||
case vbo_type::TEMPORARY:
|
case vbo_type::IMMEDIATE:
|
||||||
type_label = "Temporary";
|
type_label = "Immediate";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
@@ -584,14 +576,14 @@ void KRMeshManager::KRVBOData::load(VkCommandBuffer& commandBuffer)
|
|||||||
, debug_label
|
, debug_label
|
||||||
#endif // KRENGINE_DEBUG_GPU_LABELS
|
#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);
|
device.graphicsUpload(commandBuffer, *m_data, allocation.vertex_buffer);
|
||||||
} else {
|
} else {
|
||||||
device.streamUpload(*m_data, allocation.vertex_buffer);
|
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
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
snprintf(debug_label, KRENGINE_DEBUG_GPU_LABEL_MAX_LEN, "%s Indexes: %s", type_label, m_debugLabel);
|
snprintf(debug_label, KRENGINE_DEBUG_GPU_LABEL_MAX_LEN, "%s Indexes: %s", type_label, m_debugLabel);
|
||||||
#endif // KRENGINE_DEBUG_GPU_LABELS
|
#endif // KRENGINE_DEBUG_GPU_LABELS
|
||||||
@@ -605,7 +597,7 @@ void KRMeshManager::KRVBOData::load(VkCommandBuffer& commandBuffer)
|
|||||||
, debug_label
|
, debug_label
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (m_type == vbo_type::TEMPORARY) {
|
if (m_type == vbo_type::IMMEDIATE) {
|
||||||
device.graphicsUpload(commandBuffer, *m_index_data, allocation.index_buffer);
|
device.graphicsUpload(commandBuffer, *m_index_data, allocation.index_buffer);
|
||||||
} else {
|
} else {
|
||||||
device.streamUpload(*m_index_data, allocation.index_buffer);
|
device.streamUpload(*m_index_data, allocation.index_buffer);
|
||||||
|
|||||||
@@ -70,8 +70,14 @@ public:
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
STREAMING,
|
STREAMING,
|
||||||
|
// STREAMING data is loaded asynchronously, with transfer queues in the streamer thread.
|
||||||
|
|
||||||
CONSTANT,
|
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;
|
} vbo_type;
|
||||||
|
|
||||||
KRVBOData();
|
KRVBOData();
|
||||||
|
|||||||
Reference in New Issue
Block a user