Work::Work(const Device& device, const ComputeSize& computeSize, const SpirvBinary& spirv, const SpecConstInfo& additionalSpecConstInfo) : mComputeSize(computeSize), mDevice(device) { vk::ShaderModule shaderModule = device.GetShaderModule(spirv); SPIRV::Reflection reflection(spirv); if (reflection.GetShaderStage() != vk::ShaderStageFlagBits::eCompute) throw std::runtime_error("only compute supported"); mPipelineLayout = {{reflection}}; auto layout = device.GetLayoutManager().GetPipelineLayout(mPipelineLayout); SpecConstInfo specConstInfo = additionalSpecConstInfo; assert(mComputeSize.LocalSize.x > 0 && mComputeSize.LocalSize.y > 0); if (mComputeSize.LocalSize.y != 1) { Detail::InsertSpecConst(specConstInfo, SpecConstValue(1, mComputeSize.LocalSize.x), SpecConstValue(2, mComputeSize.LocalSize.y)); mPipeline = device.GetPipelineCache().CreateComputePipeline(shaderModule, layout, specConstInfo); } else { Detail::InsertSpecConst(specConstInfo, SpecConstValue(1, mComputeSize.LocalSize.x)); mPipeline = device.GetPipelineCache().CreateComputePipeline(shaderModule, layout, specConstInfo); } }