This commit is contained in:
Mars 2024-10-11 22:34:15 -04:00
parent 7dafdfffa6
commit fdc9507670
Signed by untrusted user: pupbrained
GPG key ID: 874E22DF2F9DFCB5
3 changed files with 21 additions and 20 deletions

View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1728588307, "lastModified": 1728698577,
"narHash": "sha256-Y1mO+iz3RUNfmu2m2c42BggOLV5q0z2CWyJzf1ypDLA=", "narHash": "sha256-hdbJjMr9myxGcByVlR9zAbQsWfZwl6NKzZodmyTzACc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "45093dff80ae7cdefc55abb77075d2931d6b47ca", "rev": "d4c28e77c38d73b23346656c102a94d90af3cf60",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -2,7 +2,7 @@ project(
'graphics-test', 'graphics-test',
'cpp', 'cpp',
version: '0.1.0', version: '0.1.0',
default_options: ['cpp_std=c++20', 'warning_level=everything', 'buildtype=debug'], default_options: ['cpp_std=c++26', 'warning_level=everything', 'buildtype=debug'],
) )
cpp = meson.get_compiler('cpp') cpp = meson.get_compiler('cpp')

View file

@ -62,9 +62,9 @@ struct Vertex {
static fn getAttributeDescriptions() -> std::array<vk::VertexInputAttributeDescription, 3> { static fn getAttributeDescriptions() -> std::array<vk::VertexInputAttributeDescription, 3> {
return { return {
{ { 0, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, pos) }, vk::VertexInputAttributeDescription(0, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, pos)),
{ 1, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, color) }, vk::VertexInputAttributeDescription(1, 0, vk::Format::eR32G32B32Sfloat, offsetof(Vertex, color)),
{ 2, 0, vk::Format::eR32G32Sfloat, offsetof(Vertex, tex_coord) } } vk::VertexInputAttributeDescription(2, 0, vk::Format::eR32G32Sfloat, offsetof(Vertex, tex_coord))
}; };
} }
@ -840,14 +840,16 @@ class VulkanApp {
.mipLevel = i - 1, .mipLevel = i - 1,
.baseArrayLayer = 0, .baseArrayLayer = 0,
.layerCount = 1 }, .layerCount = 1 },
.srcOffsets = std::array<vk::Offset3D, 2> { { { 0, 0, 0 }, { mipWidth, mipHeight, 1 } } }, .srcOffsets = std::array<vk::Offset3D, 2> { { { .x = 0, .y = 0, .z = 0 },
{ .x = mipWidth, .y = mipHeight, .z = 1 } } },
.dstSubresource = { .aspectMask = vk::ImageAspectFlagBits::eColor, .dstSubresource = { .aspectMask = vk::ImageAspectFlagBits::eColor,
.mipLevel = i, .mipLevel = i,
.baseArrayLayer = 0, .baseArrayLayer = 0,
.layerCount = 1 }, .layerCount = 1 },
.dstOffsets = .dstOffsets =
std::array<vk::Offset3D, 2> { std::array<vk::Offset3D, 2> {
{ { 0, 0, 0 }, { mipWidth > 1 ? mipWidth / 2 : 1, mipHeight > 1 ? mipHeight / 2 : 1, 1 } } } { { .x = 0, .y = 0, .z = 0 },
{ .x = mipWidth > 1 ? mipWidth / 2 : 1, .y = mipHeight > 1 ? mipHeight / 2 : 1, .z = 1 } } }
}; };
commandBuffer->blitImage( commandBuffer->blitImage(
@ -1022,8 +1024,7 @@ class VulkanApp {
.baseMipLevel = 0, .baseMipLevel = 0,
.levelCount = mipLevels, .levelCount = mipLevels,
.baseArrayLayer = 0, .baseArrayLayer = 0,
.layerCount = 1 } .layerCount = 1 } // clang-format on
// clang-format on
}; };
vk::PipelineStageFlags sourceStage; vk::PipelineStageFlags sourceStage;
@ -1062,8 +1063,8 @@ class VulkanApp {
.mipLevel = 0, .mipLevel = 0,
.baseArrayLayer = 0, .baseArrayLayer = 0,
.layerCount = 1 }, .layerCount = 1 },
.imageOffset = { 0, 0, 0 }, .imageOffset = { .x = 0, .y = 0, .z = 0 },
.imageExtent = { width, height, 1 }, .imageExtent = { .width = width, .height = height, .depth = 1 },
}; };
commandBuffer->copyBufferToImage(buffer, image, vk::ImageLayout::eTransferDstOptimal, 1, &region); commandBuffer->copyBufferToImage(buffer, image, vk::ImageLayout::eTransferDstOptimal, 1, &region);
@ -1086,14 +1087,14 @@ class VulkanApp {
for (const tinyobj::index_t& index : shape.mesh.indices) { for (const tinyobj::index_t& index : shape.mesh.indices) {
Vertex vertex { Vertex vertex {
.pos = { .pos = {
attrib.vertices[static_cast<u32>(3 * index.vertex_index + 0)], attrib.vertices[static_cast<u32>((3 * index.vertex_index) + 0)],
attrib.vertices[static_cast<u32>(3 * index.vertex_index + 1)], attrib.vertices[static_cast<u32>((3 * index.vertex_index) + 1)],
attrib.vertices[static_cast<u32>(3 * index.vertex_index + 2)], attrib.vertices[static_cast<u32>((3 * index.vertex_index) + 2)],
}, },
.color = { 1.0F, 1.0F, 1.0F }, .color = { 1.0F, 1.0F, 1.0F },
.tex_coord = { .tex_coord = {
attrib.texcoords[static_cast<u32>(2 * index.texcoord_index + 0)], attrib.texcoords[static_cast<u32>((2 * index.texcoord_index) + 0)],
1.0F - attrib.texcoords[static_cast<u32>(2 * index.texcoord_index + 1)], 1.0F - attrib.texcoords[static_cast<u32>((2 * index.texcoord_index) + 1)],
} }
}; };
@ -1369,7 +1370,7 @@ class VulkanApp {
}; };
vk::Rect2D scissor { vk::Rect2D scissor {
.offset = { 0, 0 }, .offset = { .x = 0, .y = 0 },
.extent = mSwapChainExtent, .extent = mSwapChainExtent,
}; };
@ -1540,7 +1541,7 @@ class VulkanApp {
u32 width = 0, height = 0; u32 width = 0, height = 0;
std::tie(width, height) = mWindow->getFramebufferSize(); std::tie(width, height) = mWindow->getFramebufferSize();
vk::Extent2D actualExtent = { width, height }; vk::Extent2D actualExtent = { .width = width, .height = height };
actualExtent.width = actualExtent.width =
std::clamp(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width); std::clamp(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width);