Added KRMesh::isReady
Vulkan test code now uses KRMesh and asset ingestion pipeline for vertex and index data. Updated Vulkan test shader to match KRMesh attribute layout.
This commit is contained in:
@@ -219,22 +219,20 @@ void KRCamera::renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeS
|
||||
GL_POP_GROUP_MARKER;
|
||||
|
||||
// ---------- Start: Vulkan Debug Code ----------
|
||||
KRMeshManager::KRVBOData& testVertices = getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES;
|
||||
bool haveMesh = testVertices.isVBOReady();
|
||||
|
||||
if (haveMesh) {
|
||||
KRMesh* sphereMesh = getContext().getMeshManager()->getMaxLODModel("__sphere");
|
||||
if (sphereMesh && sphereMesh->isReady()) {
|
||||
PipelineInfo info{};
|
||||
std::string shader_name("vulkan_test");
|
||||
info.shader_name = &shader_name;
|
||||
info.pCamera = this;
|
||||
info.renderPass = KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
|
||||
info.rasterMode = PipelineInfo::RasterMode::kAlphaBlend;
|
||||
info.vertexAttributes = testVertices.getVertexAttributes();
|
||||
info.modelFormat = KRMesh::model_format_t::KRENGINE_MODEL_FORMAT_STRIP;
|
||||
info.vertexAttributes = sphereMesh->getVertexAttributes();
|
||||
info.modelFormat = sphereMesh->getModelFormat();
|
||||
KRPipeline* testPipeline = m_pContext->getPipelineManager()->getPipeline(compositeSurface, info);
|
||||
testPipeline->bind(commandBuffer);
|
||||
testVertices.bind(commandBuffer);
|
||||
vkCmdDraw(commandBuffer, 4, 1, 0, 0);
|
||||
sphereMesh->renderNoMaterials(commandBuffer, info.renderPass, "Vulkan Test", "vulkan_test", 1.0);
|
||||
}
|
||||
|
||||
// ---------- End: Vulkan Debug Code ----------
|
||||
|
||||
@@ -435,6 +435,21 @@ void KRMesh::renderNoMaterials(VkCommandBuffer& commandBuffer, KRNode::RenderPas
|
||||
}
|
||||
}
|
||||
|
||||
bool KRMesh::isReady() const
|
||||
{
|
||||
// TODO - This should be cached...
|
||||
int submesh_count = getSubmeshCount();
|
||||
for (int i = 0; i < submesh_count; i++) {
|
||||
for (int j = 0; j < m_submeshes[i]->vbo_data_blocks.size(); j++) {
|
||||
KRMeshManager::KRVBOData* vbo_data_block = m_submeshes[i]->vbo_data_blocks[j];
|
||||
if (!vbo_data_block->isVBOReady()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void KRMesh::renderSubmesh(VkCommandBuffer& commandBuffer, int iSubmesh, KRNode::RenderPass renderPass, const std::string &object_name, const std::string &material_name, float lodCoverage) {
|
||||
getSubmeshes();
|
||||
|
||||
@@ -460,7 +475,8 @@ void KRMesh::renderSubmesh(VkCommandBuffer& commandBuffer, int iSubmesh, KRNode:
|
||||
int vertex_draw_count = cVertexes;
|
||||
if(vertex_draw_count > index_count - index_group_offset) vertex_draw_count = index_count - index_group_offset;
|
||||
|
||||
glDrawElements(GL_TRIANGLES, vertex_draw_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(index_group_offset * 2));
|
||||
//glDrawElements(GL_TRIANGLES, vertex_draw_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(index_group_offset * 2));
|
||||
vkCmdDrawIndexed(commandBuffer, vertex_draw_count, 1, index_group_offset, 0, 0);
|
||||
m_pContext->getMeshManager()->log_draw_call(renderPass, object_name, material_name, vertex_draw_count);
|
||||
cVertexes -= vertex_draw_count;
|
||||
index_group_offset = 0;
|
||||
|
||||
@@ -128,6 +128,7 @@ public:
|
||||
void optimizeIndexes();
|
||||
|
||||
void renderNoMaterials(VkCommandBuffer& commandBuffer, KRNode::RenderPass renderPass, const std::string& object_name, const std::string& material_name, float lodCoverage);
|
||||
bool isReady() const;
|
||||
|
||||
float getMaxDimension();
|
||||
|
||||
|
||||
@@ -5,17 +5,11 @@
|
||||
|
||||
layout(location = 0) out vec3 fragColor;
|
||||
layout(location = 0) in vec3 vertex_position;
|
||||
layout(location = 1) in vec3 vertex_uv;
|
||||
layout(location = 1) in vec3 vertex_normal;
|
||||
layout(location = 2) in vec3 vertex_tangent;
|
||||
layout(constant_id = 0) const int QUALITY_LEVEL = 64; // Specialization constant test
|
||||
|
||||
vec3 colors[4] = vec3[](
|
||||
vec3(1.0, 0.0, 0.0),
|
||||
vec3(0.0, 1.0, 0.0),
|
||||
vec3(0.0, 0.0, 1.0),
|
||||
vec3(1.0, 0.0, 1.0)
|
||||
);
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(vertex_position * 0.5, 1.0);
|
||||
fragColor = colors[gl_VertexIndex];
|
||||
fragColor = vertex_normal * 0.25 + vec3(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user