asset_manager concept
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user