Files
sophia/sandbox/material.hpp
T
2026-10-07 11:51:14 -07:00

53 lines
1.1 KiB
C++

#pragma once
#include <memory>
#include <sophia/math.hpp>
#include <vulkan/vulkan.hpp>
#include "vulkan/device.hpp"
#include "vulkan/pipelines/graphics_pipeline.hpp"
#include "vulkan/shader.hpp"
namespace sophia {
class Material {
public:
struct PushConstants {
vk::DeviceAddress data0;
u64 padding;
vec4 data1;
vec4 data2;
vec4 data3;
};
Material(const Material&) = delete;
Material& operator=(const Material&) = delete;
Material(Device& device, std::unique_ptr<Shader> vertexShader,
std::unique_ptr<Shader> fragmentShader, vk::Format colorFormat,
vk::Format depthFormat);
~Material();
void bind(vk::CommandBuffer commandBuffer) const {
pipeline->bind(commandBuffer);
}
vk::PipelineLayout getLayout() const { return pipelineLayout.get(); }
private:
void createPipelineLayout(Device& device);
vk::UniquePipelineLayout pipelineLayout;
std::unique_ptr<GraphicsPipeline> pipeline;
};
struct MaterialInstance {
Material* material;
};
// !NOTE: eventually add ecs support for ecs
// struct MaterialComponent {
// MaterialInstanceHandle handle;
// };
} // namespace sophia