Skip to content
Snippets Groups Projects
Commit 086acb21 authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#69] tried to fix some things...

parent 4ed3dea8
No related branches found
No related tags found
1 merge request!56Resolve "Partikelsystem"
Pipeline #25489 failed
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
#include <chrono> #include <chrono>
int main(int argc, const char** argv) { int main(int argc, const char** argv) {
const char* applicationName = "First Triangle"; const char* applicationName = "Particlesystem";
const int windowWidth = 800; uint32_t windowWidth = 800;
const int windowHeight = 600; uint32_t windowHeight = 600;
vkcv::Window window = vkcv::Window::create( vkcv::Window window = vkcv::Window::create(
applicationName, applicationName,
windowWidth, windowWidth,
windowHeight, windowHeight,
false true
); );
vkcv::CameraManager cameraManager(window, windowWidth, windowHeight); vkcv::CameraManager cameraManager(window, windowWidth, windowHeight);
...@@ -53,34 +53,15 @@ int main(int argc, const char** argv) { ...@@ -53,34 +53,15 @@ int main(int argc, const char** argv) {
uint16_t indices[3] = { 0, 1, 2 }; uint16_t indices[3] = { 0, 1, 2 };
triangleIndexBuffer.fill(&indices[0], sizeof(indices)); triangleIndexBuffer.fill(&indices[0], sizeof(indices));
vkcv::SamplerHandle sampler = core.createSampler(
vkcv::SamplerFilterType::NEAREST,
vkcv::SamplerFilterType::NEAREST,
vkcv::SamplerMipmapMode::NEAREST,
vkcv::SamplerAddressMode::REPEAT
);
std::cout << "Physical device: " << physicalDevice.getProperties().deviceName << std::endl; std::cout << "Physical device: " << physicalDevice.getProperties().deviceName << std::endl;
switch (physicalDevice.getProperties().vendorID) {
case 0x1002: std::cout << "Running AMD huh? You like underdogs, are you a Linux user?" << std::endl; break;
case 0x10DE: std::cout << "An NVidia GPU, how predictable..." << std::endl; break;
case 0x8086: std::cout << "Poor child, running on an Intel GPU, probably integrated..."
"or perhaps you are from the future with a dedicated one?" << std::endl; break;
case 0x13B5: std::cout << "ARM? What the hell are you running on, next thing I know you're trying to run Vulkan on a leg..." << std::endl; break;
default: std::cout << "Unknown GPU vendor?! Either you're on an exotic system or your driver is broken..." << std::endl;
}
// an example attachment for passes that output to the window // an example attachment for passes that output to the window
const vkcv::AttachmentDescription present_color_attachment( const vkcv::AttachmentDescription present_color_attachment(
vkcv::AttachmentLayout::UNDEFINED,
vkcv::AttachmentLayout::COLOR_ATTACHMENT,
vkcv::AttachmentLayout::PRESENTATION,
vkcv::AttachmentOperation::STORE, vkcv::AttachmentOperation::STORE,
vkcv::AttachmentOperation::CLEAR, vkcv::AttachmentOperation::CLEAR,
core.getSwapchainImageFormat()); core.getSwapchainImageFormat());
vkcv::PassConfig particlePassDefinition({ present_color_attachment }); vkcv::PassConfig particlePassDefinition({ present_color_attachment });
vkcv::PassHandle particlePass = core.createPass(particlePassDefinition); vkcv::PassHandle particlePass = core.createPass(particlePassDefinition);
...@@ -96,18 +77,19 @@ int main(int argc, const char** argv) { ...@@ -96,18 +77,19 @@ int main(int argc, const char** argv) {
particleShaderProgram.reflectShader(vkcv::ShaderStage::VERTEX); particleShaderProgram.reflectShader(vkcv::ShaderStage::VERTEX);
particleShaderProgram.reflectShader(vkcv::ShaderStage::FRAGMENT); particleShaderProgram.reflectShader(vkcv::ShaderStage::FRAGMENT);
vkcv::DescriptorSetConfig setConfig({ std::vector<vkcv::DescriptorBinding> descriptorBindings = {
vkcv::DescriptorBinding(vkcv::DescriptorType::UNIFORM_BUFFER, 1, vkcv::ShaderStage::FRAGMENT), vkcv::DescriptorBinding(vkcv::DescriptorType::UNIFORM_BUFFER, 1, vkcv::ShaderStage::FRAGMENT)};
}); vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorBindings);
vkcv::ResourcesHandle set = core.createResourceDescription({setConfig});
const vkcv::PipelineConfig particlePipelineDefinition( const vkcv::PipelineConfig particlePipelineDefinition(
particleShaderProgram, particleShaderProgram,
windowWidth, UINT32_MAX,
windowHeight, UINT32_MAX,
particlePass, particlePass,
{}, {},
{core.getDescriptorSetLayout(set, 0)}); { core.getDescriptorSet(descriptorSet).layout },
true);
vkcv::PipelineHandle particlePipeline = core.createGraphicsPipeline(particlePipelineDefinition); vkcv::PipelineHandle particlePipeline = core.createGraphicsPipeline(particlePipelineDefinition);
vkcv::Buffer<glm_vec4> color = core.createBuffer<glm_vec4>( vkcv::Buffer<glm_vec4> color = core.createBuffer<glm_vec4>(
vkcv::BufferType::UNIFORM, vkcv::BufferType::UNIFORM,
...@@ -116,7 +98,7 @@ int main(int argc, const char** argv) { ...@@ -116,7 +98,7 @@ int main(int argc, const char** argv) {
vkcv::DescriptorWrites setWrites; vkcv::DescriptorWrites setWrites;
setWrites.uniformBufferWrites = {vkcv::UniformBufferDescriptorWrite(0,color.getHandle())}; setWrites.uniformBufferWrites = {vkcv::UniformBufferDescriptorWrite(0,color.getHandle())};
core.writeResourceDescription(set,0,setWrites); core.writeResourceDescription(descriptorSet,0,setWrites);
if (!particlePipeline) if (!particlePipeline)
{ {
...@@ -124,30 +106,40 @@ int main(int argc, const char** argv) { ...@@ -124,30 +106,40 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
std::vector<vkcv::VertexBufferBinding> vertexBufferBindings; const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
const vkcv::Mesh renderMesh({}, triangleIndexBuffer.getVulkanHandle(), 3);
vkcv::DrawcallInfo drawcalls(renderMesh, {});
auto start = std::chrono::system_clock::now(); auto start = std::chrono::system_clock::now();
while (window.isWindowOpen()) while (window.isWindowOpen())
{ {
core.beginFrame();
window.pollEvents(); window.pollEvents();
uint32_t swapchainWidth, swapchainHeight;
if (!core.beginFrame(swapchainWidth, swapchainHeight)) {
continue;
}
auto end = std::chrono::system_clock::now(); auto end = std::chrono::system_clock::now();
auto deltatime = end - start; auto deltatime = end - start;
start = end; start = end;
cameraManager.getCamera().updateView(std::chrono::duration<double>(deltatime).count()); cameraManager.getCamera().updateView(std::chrono::duration<double>(deltatime).count());
const glm::mat4 mvp = cameraManager.getCamera().getProjection() * cameraManager.getCamera().getView(); const glm::mat4 mvp = cameraManager.getCamera().getProjection() * cameraManager.getCamera().getView();
core.renderMesh( vkcv::PushConstantData pushConstantData((void*)&mvp, sizeof(glm::mat4));
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
core.recordDrawcallsToCmdStream(
cmdStream,
particlePass, particlePass,
particlePipeline, particlePipeline,
sizeof(mvp), pushConstantData,
&mvp, {drawcalls},
vertexBufferBindings, {swapchainInput});
triangleIndexBuffer.getHandle(), core.prepareSwapchainImageForPresent(cmdStream);
3, core.submitCommandStream(cmdStream);
vkcv::ResourcesHandle(),
0);
core.endFrame(); core.endFrame();
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment