mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
lsfg-vk-v3.1p: alpha shaders
This commit is contained in:
parent
0b4caa7126
commit
2d66e1cade
2 changed files with 23 additions and 25 deletions
|
|
@ -51,10 +51,10 @@ namespace LSFG::Shaders {
|
|||
std::array<Core::DescriptorSet, 3> lastDescriptorSet;
|
||||
|
||||
Core::Image inImg;
|
||||
std::array<Core::Image, 2> tempImgs1;
|
||||
std::array<Core::Image, 2> tempImgs2;
|
||||
std::array<Core::Image, 4> tempImgs3;
|
||||
std::array<std::array<Core::Image, 4>, 3> outImgs;
|
||||
Core::Image tempImg1;
|
||||
Core::Image tempImg2;
|
||||
std::array<Core::Image, 2> tempImgs3;
|
||||
std::array<std::array<Core::Image, 2>, 3> outImgs;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ Alpha::Alpha(Vulkan& vk, Core::Image inImg) : inImg(std::move(inImg)) {
|
|||
vk.shaders.getShader(vk.device, "alpha[0]",
|
||||
{ { 1, VK_DESCRIPTOR_TYPE_SAMPLER },
|
||||
{ 1, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE },
|
||||
{ 2, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } }),
|
||||
{ 1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } }),
|
||||
vk.shaders.getShader(vk.device, "alpha[1]",
|
||||
{ { 1, VK_DESCRIPTOR_TYPE_SAMPLER },
|
||||
{ 2, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE },
|
||||
{ 2, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } }),
|
||||
{ 1, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE },
|
||||
{ 1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } }),
|
||||
vk.shaders.getShader(vk.device, "alpha[2]",
|
||||
{ { 1, VK_DESCRIPTOR_TYPE_SAMPLER },
|
||||
{ 2, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE },
|
||||
{ 4, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } }),
|
||||
{ 1, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE },
|
||||
{ 2, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } }),
|
||||
vk.shaders.getShader(vk.device, "alpha[3]",
|
||||
{ { 1, VK_DESCRIPTOR_TYPE_SAMPLER },
|
||||
{ 4, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE },
|
||||
{ 4, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } })
|
||||
{ 2, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE },
|
||||
{ 2, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE } })
|
||||
}};
|
||||
this->pipelines = {{
|
||||
vk.shaders.getPipeline(vk.device, "alpha[0]"),
|
||||
|
|
@ -49,16 +49,14 @@ Alpha::Alpha(Vulkan& vk, Core::Image inImg) : inImg(std::move(inImg)) {
|
|||
.width = (extent.width + 1) >> 1,
|
||||
.height = (extent.height + 1) >> 1
|
||||
};
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
this->tempImgs1.at(i) = Core::Image(vk.device, halfExtent);
|
||||
this->tempImgs2.at(i) = Core::Image(vk.device, halfExtent);
|
||||
}
|
||||
this->tempImg1 = Core::Image(vk.device, halfExtent);
|
||||
this->tempImg2 = Core::Image(vk.device, halfExtent);
|
||||
|
||||
const VkExtent2D quarterExtent = {
|
||||
.width = (halfExtent.width + 1) >> 1,
|
||||
.height = (halfExtent.height + 1) >> 1
|
||||
};
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
this->tempImgs3.at(i) = Core::Image(vk.device, quarterExtent);
|
||||
for (size_t j = 0; j < 3; j++)
|
||||
this->outImgs.at(j).at(i) = Core::Image(vk.device, quarterExtent);
|
||||
|
|
@ -68,16 +66,16 @@ Alpha::Alpha(Vulkan& vk, Core::Image inImg) : inImg(std::move(inImg)) {
|
|||
this->descriptorSets.at(0).update(vk.device)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, this->sampler)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->inImg)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImg1)
|
||||
.build();
|
||||
this->descriptorSets.at(1).update(vk.device)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, this->sampler)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->tempImgs1)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs2)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->tempImg1)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImg2)
|
||||
.build();
|
||||
this->descriptorSets.at(2).update(vk.device)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLER, this->sampler)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->tempImgs2)
|
||||
.add(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, this->tempImg2)
|
||||
.add(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, this->tempImgs3)
|
||||
.build();
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
|
|
@ -90,13 +88,13 @@ Alpha::Alpha(Vulkan& vk, Core::Image inImg) : inImg(std::move(inImg)) {
|
|||
|
||||
void Alpha::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount) {
|
||||
// first pass
|
||||
const auto halfExtent = this->tempImgs1.at(0).getExtent();
|
||||
const auto halfExtent = this->tempImg1.getExtent();
|
||||
uint32_t threadsX = (halfExtent.width + 7) >> 3;
|
||||
uint32_t threadsY = (halfExtent.height + 7) >> 3;
|
||||
|
||||
Utils::BarrierBuilder(buf)
|
||||
.addW2R(this->inImg)
|
||||
.addR2W(this->tempImgs1)
|
||||
.addR2W(this->tempImg1)
|
||||
.build();
|
||||
|
||||
this->pipelines.at(0).bind(buf);
|
||||
|
|
@ -105,8 +103,8 @@ void Alpha::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount) {
|
|||
|
||||
// second pass
|
||||
Utils::BarrierBuilder(buf)
|
||||
.addW2R(this->tempImgs1)
|
||||
.addR2W(this->tempImgs2)
|
||||
.addW2R(this->tempImg1)
|
||||
.addR2W(this->tempImg2)
|
||||
.build();
|
||||
|
||||
this->pipelines.at(1).bind(buf);
|
||||
|
|
@ -119,7 +117,7 @@ void Alpha::Dispatch(const Core::CommandBuffer& buf, uint64_t frameCount) {
|
|||
threadsY = (quarterExtent.height + 7) >> 3;
|
||||
|
||||
Utils::BarrierBuilder(buf)
|
||||
.addW2R(this->tempImgs2)
|
||||
.addW2R(this->tempImg2)
|
||||
.addR2W(this->tempImgs3)
|
||||
.build();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue