asset_manager concept

This commit is contained in:
2026-09-09 11:36:07 -07:00
parent 9aef3f57fc
commit 4190ff847b
14 changed files with 525 additions and 12 deletions
+8 -8
View File
@@ -1,6 +1,6 @@
#include "model_render_system.hpp"
#include <cassert>
#include <sophia/util/assert.hpp>
#include "shaders/model_render_system.frag.spv.h"
#include "shaders/model_render_system.vert.spv.h"
@@ -12,8 +12,8 @@ ModelRenderSystem::ModelRenderSystem(Device& device,
: device{device}, renderContext{renderContext} {
createPipelineLayout();
assert(this->pipelineLayout.get() != nullptr &&
"Cannot create pipeline before pipeline layout");
SOPHIA_ASSERT(this->pipelineLayout.get() != nullptr,
"Cannot create pipeline before pipeline layout");
auto vertexShader = Shader::Builder()
.fromSPIRV(shaders::model_render_system_vert_spv)
@@ -42,23 +42,23 @@ ModelRenderSystem::~ModelRenderSystem() {
}
void ModelRenderSystem::render(vk::CommandBuffer commandBuffer,
std::span<const std::unique_ptr<Mesh>> meshes,
std::span<const MeshInstance> instances,
const FrameInfo& frameInfo) {
glm::mat4 viewProjection = frameInfo.camera.getViewProjection();
this->graphicsPipeline->bind(commandBuffer);
for (const std::unique_ptr<Mesh>& mesh : meshes) {
for (const MeshInstance& instance : instances) {
PushConstantData push{};
push.modelMatrix = viewProjection;
push.transform = viewProjection * instance.transform;
commandBuffer.pushConstants(
this->pipelineLayout.get(),
vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment,
0, sizeof(PushConstantData), &push);
mesh->bind(commandBuffer);
mesh->draw(commandBuffer);
instance.mesh->bind(commandBuffer);
instance.mesh->draw(commandBuffer);
}
}