quick commit
This commit is contained in:
@@ -50,36 +50,32 @@ void A2Task1SolutionKernelDecomposition::compute()
|
||||
vk::CommandBufferBeginInfo beginInfo(vk::CommandBufferUsageFlagBits::eOneTimeSubmit);
|
||||
|
||||
cb.begin(beginInfo);
|
||||
cb.bindPipeline(vk::PipelineBindPoint::eCompute, pipeline);
|
||||
|
||||
// TODO: Implement reduction with kernel decomposition
|
||||
// NOTE: make sure that activeBuffer points to the buffer with the final result in the end
|
||||
// That buffer is read back for the correctness check
|
||||
// (A2Task1SolutionKernelDecomposition::result())
|
||||
// HINT: You can alternate between the two provided descriptor sets to implement ping-pong
|
||||
|
||||
uint blocksize = 512;
|
||||
uint kernelCount = mpInput->size() / blocksize;
|
||||
uint blocksize = workGroupSize * 2;
|
||||
uint windowSize = mpInput->size();
|
||||
PushConstant p;
|
||||
|
||||
for (; kernelCount > 0; kernelCount /= 2)
|
||||
activeBuffer = 1;
|
||||
|
||||
while (windowSize > 1)
|
||||
{
|
||||
activeBuffer = activeBuffer == 0 ? 1 : 0;
|
||||
activeBuffer = 1 - activeBuffer;
|
||||
uint numGroups = (windowSize + blocksize - 1) / blocksize;
|
||||
|
||||
cb.bindDescriptorSets(vk::PipelineBindPoint::eCompute, pipelineLayout, 0U, 1U, &descriptorSets[activeBuffer], 0U, nullptr);
|
||||
p.size = blocksize;
|
||||
p.offset = windowSize;
|
||||
|
||||
cb.pushConstants(pipelineLayout, vk::ShaderStageFlagBits::eCompute, 0, sizeof(PushConstant), &p);
|
||||
|
||||
// for loop to call each kernel
|
||||
for (int i = 0; i < kernelCount; i++)
|
||||
{
|
||||
cb.dispatch(i * blocksize, 0, 0);
|
||||
}
|
||||
cb.dispatch(numGroups, 1, 1);
|
||||
|
||||
vk::MemoryBarrier memoryBarrier(vk::AccessFlagBits::eShaderWrite, vk::AccessFlagBits::eShaderRead);
|
||||
cb.pipelineBarrier(vk::PipelineStageFlagBits::eComputeShader, vk::PipelineStageFlagBits::eComputeShader, vk::DependencyFlags(), 1, &memoryBarrier, 0, nullptr, 0, nullptr);
|
||||
|
||||
std::cout << "deine mum \n" ;
|
||||
windowSize = numGroups;
|
||||
}
|
||||
// todo check which buffer is active and read from that one
|
||||
cb.end();
|
||||
|
||||
vk::SubmitInfo submitInfo = vk::SubmitInfo(0, nullptr, nullptr, 1, &cb);
|
||||
@@ -97,7 +93,7 @@ void A2Task1SolutionKernelDecomposition::compute()
|
||||
uint A2Task1SolutionKernelDecomposition::result() const
|
||||
{
|
||||
std::vector<uint> result(1, 0);
|
||||
fillHostWithStagingBuffer<uint>(app.pDevice, app.device, app.transferCommandPool, app.transferQueue, buffers[activeBuffer], result);
|
||||
fillHostWithStagingBuffer<uint>(app.pDevice, app.device, app.transferCommandPool, app.transferQueue, buffers[1 - activeBuffer], result);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user