I am trying to make a shader that stalls my program as so:
#version 450
layout (local_size_x = 16, local_size_y = 16) in;
void main()
{
while(true) {}
}
I am trying to call the pipeline associated with the shader like this:
static void GpuCompute(
EffectFramework& frame_work,
const std::string& shader_path)
{
auto& pipeline = frame_work.GetPipeline(shader_path);
auto h_interface = HardwareInterface::h_interface;
auto& device = h_interface->GetDevice();
auto& cmd_pool = h_interface->GetCommandPool();
auto& cmd_buffer = h_interface->GetCmdBufferTmp();
auto& queue = h_interface->GetQueue();
vk::CommandBufferAllocateInfo alloc_info(
cmd_pool, vk::CommandBufferLevel::ePrimary, 1);
auto [result, buffers] = device.allocateCommandBuffersUnique(alloc_info);
if(result != vk::Result::eSuccess)
Log::RecordLogError("Failed to create command buffers");
cmd_buffer = std::move(buffers[0]);
vk::CommandBufferBeginInfo begin_info(
vk::CommandBufferUsageFlagBits::eSimultaneousUse, nullptr);
vk::FenceCreateInfo fence_create_info = {};
fence_create_info.flags = {};
auto[result_f, fence] = device.createFenceUnique(fence_create_info);
if(result_f != vk::Result::eSuccess)
Log::RecordLogError("Failed to create compute fence");
result = cmd_buffer->begin(&begin_info);
if(result != vk::Result::eSuccess)
Log::RecordLogError("Failed to begin recording command buffer!");
_SetName(device, *cmd_buffer, "compute_cmd_buffer");
cmd_buffer->bindPipeline(vk::PipelineBindPoint::eCompute, pipeline.GetPipeline());
cmd_buffer->dispatch(1920 / 16, 1440 / 16, 1);
cmd_buffer->end();
vk::SubmitInfo submit_info = {};
submit_info.commandBufferCount = 1;
submit_info.pCommandBuffers = &*cmd_buffer;
queue.submit(1, &submit_info, *fence);
device.waitForFences(1,
&*fence,
VK_TRUE,
std::numeric_limits<uint64_t>::max());
}
However when I run my program it doesn't stall. I used renderdoc to make sure I was calling the shader:
It seems that the dispatch call is using the correct shader.
So why does my code run? It should get stuck computing that loop until the heat death of the universe.
The way I know it's not stalled is, I am also rendering graphics after calling the compute shader, on the same queue and on the same threa. To my understanding, commands submitted to the same queue execute sequentially so this shader should stall the entire pipeline. but I can still interact with my program just fine.

