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

View file

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

View file

@ -2,7 +2,7 @@ project(
'graphics-test',
'cpp',
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')

View file

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