Skip to content

Commit

Permalink
Simplified test code.
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe2933 committed Sep 23, 2024
1 parent 2e2a354 commit aeff8f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 35 deletions.
32 changes: 9 additions & 23 deletions test/get_mip_view_create_infos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,23 @@ struct Gpu : vku::Gpu<QueueFamilies, Queues> {
};

struct ColorCheckComputer {
struct DescriptorSetLayout : vku::DescriptorSetLayout<vk::DescriptorType::eSampledImage, vk::DescriptorType::eStorageBuffer> {
explicit DescriptorSetLayout(const vk::raii::Device &device [[clang::lifetimebound]], std::uint32_t mipLevels)
: vku::DescriptorSetLayout<vk::DescriptorType::eSampledImage, vk::DescriptorType::eStorageBuffer> {
device, vk::DescriptorSetLayoutCreateInfo {
{},
vku::unsafeProxy({
vk::DescriptorSetLayoutBinding { 0, vk::DescriptorType::eSampledImage, mipLevels, vk::ShaderStageFlagBits::eCompute },
vk::DescriptorSetLayoutBinding { 1, vk::DescriptorType::eStorageBuffer, 1, vk::ShaderStageFlagBits::eCompute },
}),
}
} { }
};

struct PushConstant {
std::array<float, 4> color;
std::uint32_t mipLevel;
};

DescriptorSetLayout descriptorSetLayout;
vku::DescriptorSetLayout<vk::DescriptorType::eSampledImage, vk::DescriptorType::eStorageBuffer> descriptorSetLayout;
vk::raii::PipelineLayout pipelineLayout;
vk::raii::Pipeline pipeline;

explicit ColorCheckComputer(const vk::raii::Device &device [[clang::lifetimebound]], std::uint32_t mipLevels)
: descriptorSetLayout { device, mipLevels }
: descriptorSetLayout { device, {
{},
vku::unsafeProxy({
vk::DescriptorSetLayoutBinding { 0, vk::DescriptorType::eSampledImage, mipLevels, vk::ShaderStageFlagBits::eCompute },
vk::DescriptorSetLayoutBinding { 1, vk::DescriptorType::eStorageBuffer, 1, vk::ShaderStageFlagBits::eCompute },
}),
} }
, pipelineLayout { device, vk::PipelineLayoutCreateInfo {
{},
*descriptorSetLayout,
Expand Down Expand Up @@ -180,14 +173,7 @@ int main() {

const ColorCheckComputer colorCheckComputer { gpu.device, image.mipLevels };

const vk::raii::DescriptorPool descriptorPool { gpu.device, vk::DescriptorPoolCreateInfo {
{},
1,
vku::unsafeProxy({
vk::DescriptorPoolSize { vk::DescriptorType::eSampledImage, image.mipLevels },
vk::DescriptorPoolSize { vk::DescriptorType::eStorageBuffer, 1 },
}),
} };
const vk::raii::DescriptorPool descriptorPool { gpu.device, getPoolSizes(colorCheckComputer.descriptorSetLayout).getDescriptorPoolCreateInfo() };
const auto [descriptorSet] = vku::allocateDescriptorSets(*gpu.device, *descriptorPool, std::tie(colorCheckComputer.descriptorSetLayout));
gpu.device.updateDescriptorSets({
descriptorSet.getWrite<0>(vku::unsafeProxy(imageViews | std::views::transform([](const auto &imageView) {
Expand Down
17 changes: 5 additions & 12 deletions test/specialization_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,15 @@ struct Gpu : vku::Gpu<QueueFamilies, Queues> {
};

struct BufferFillComputer {
struct DescriptorSetLayout : vku::DescriptorSetLayout<vk::DescriptorType::eStorageBuffer> {
explicit DescriptorSetLayout(const vk::raii::Device &device [[clang::lifetimebound]])
: vku::DescriptorSetLayout<vk::DescriptorType::eStorageBuffer> {
device, vk::DescriptorSetLayoutCreateInfo {
{},
vku::unsafeProxy(vk::DescriptorSetLayoutBinding { 0, vk::DescriptorType::eStorageBuffer, 1, vk::ShaderStageFlagBits::eCompute }),
}
} { }
};

DescriptorSetLayout descriptorSetLayout;
vku::DescriptorSetLayout<vk::DescriptorType::eStorageBuffer> descriptorSetLayout;
vk::raii::PipelineLayout pipelineLayout;
vk::raii::Pipeline pipeline;

explicit BufferFillComputer(const vk::raii::Device &device [[clang::lifetimebound]], std::uint32_t value)
: descriptorSetLayout { device }
: descriptorSetLayout { device, {
{},
vku::unsafeProxy(vk::DescriptorSetLayoutBinding { 0, vk::DescriptorType::eStorageBuffer, 1, vk::ShaderStageFlagBits::eCompute }),
} }
, pipelineLayout { device, vk::PipelineLayoutCreateInfo {
{},
*descriptorSetLayout,
Expand Down

0 comments on commit aeff8f3

Please sign in to comment.