Vulkan compute: minor refactoring
This commit is contained in:
parent
06115a7a2d
commit
97cfcddfb3
2 changed files with 11 additions and 7 deletions
|
@ -680,7 +680,7 @@ std::optional<std::pair<int, int>> dither::internal::vulkan_minmax(
|
||||||
std::array<VkDescriptorSet, 2> minmax_desc_sets, VkBuffer max_in_buf,
|
std::array<VkDescriptorSet, 2> minmax_desc_sets, VkBuffer max_in_buf,
|
||||||
VkBuffer min_in_buf, VkBuffer max_out_buf, VkBuffer min_out_buf,
|
VkBuffer min_in_buf, VkBuffer max_out_buf, VkBuffer min_out_buf,
|
||||||
VkBuffer state_buf, const int size, const float *const filter_mapped,
|
VkBuffer state_buf, const int size, const float *const filter_mapped,
|
||||||
std::vector<bool> pbp) {
|
const std::vector<bool> &pbp) {
|
||||||
// ensure minority pixel is "true"
|
// ensure minority pixel is "true"
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
for (bool value : pbp) {
|
for (bool value : pbp) {
|
||||||
|
@ -688,17 +688,21 @@ std::optional<std::pair<int, int>> dither::internal::vulkan_minmax(
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool flip;
|
||||||
if (count * 2 >= pbp.size()) {
|
if (count * 2 >= pbp.size()) {
|
||||||
// std::cout << "MINMAX flip\n"; // DEBUG
|
flip = true;
|
||||||
for (unsigned int i = 0; i < pbp.size(); ++i) {
|
} else {
|
||||||
pbp[i] = !pbp[i];
|
flip = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<FloatAndIndex> fai(size);
|
std::vector<FloatAndIndex> fai(size);
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
fai[i].value = filter_mapped[i];
|
fai[i].value = filter_mapped[i];
|
||||||
|
if (flip) {
|
||||||
|
fai[i].pbp = pbp[i] ? 0 : 1;
|
||||||
|
} else {
|
||||||
fai[i].pbp = pbp[i] ? 1 : 0;
|
fai[i].pbp = pbp[i] ? 1 : 0;
|
||||||
|
}
|
||||||
fai[i].idx = i;
|
fai[i].idx = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ std::optional<std::pair<int, int>> vulkan_minmax(
|
||||||
std::array<VkDescriptorSet, 2> minmax_desc_sets, VkBuffer max_in_buf,
|
std::array<VkDescriptorSet, 2> minmax_desc_sets, VkBuffer max_in_buf,
|
||||||
VkBuffer min_in_buf, VkBuffer max_out_buf, VkBuffer min_out_buf,
|
VkBuffer min_in_buf, VkBuffer max_out_buf, VkBuffer min_out_buf,
|
||||||
VkBuffer state_buf, const int size, const float *const filter_mapped,
|
VkBuffer state_buf, const int size, const float *const filter_mapped,
|
||||||
std::vector<bool> pbp);
|
const std::vector<bool> &pbp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue