| 143 | } |
| 144 | |
| 145 | OmmBuildQueue::OmmBuildQueue( |
| 146 | nvrhi::DeviceHandle& device, |
| 147 | std::shared_ptr<donut::engine::DescriptorTableManager> descriptorTable, |
| 148 | std::shared_ptr<donut::engine::ShaderFactory> shaderFactory) |
| 149 | : m_device(device) |
| 150 | , m_descriptorTable(std::move(descriptorTable)) |
| 151 | , m_shaderFactory(std::move(shaderFactory)) |
| 152 | { |
| 153 | omm::GpuBakeNvrhi::ShaderProvider provider; |
| 154 | |
| 155 | provider.bindingOffsets = nvrhi::VulkanBindingOffsets { .shaderResource = 200, .sampler = 100, .constantBuffer = 300, .unorderedAccess = 400 }; |
| 156 | //provider.bindingOffsets = nvrhi::VulkanBindingOffsets { .shaderResource = UINT_MAX, .sampler = UINT_MAX, .constantBuffer = UINT_MAX, .unorderedAccess = UINT_MAX }; <- if MR gets accepted |
| 157 | |
| 158 | provider.shaders = [this](nvrhi::ShaderType type, const char* shaderName, const char* shaderEntryName)->nvrhi::ShaderHandle |
| 159 | { |
| 160 | std::vector<donut::engine::ShaderMacro> defines = { donut::engine::ShaderMacro("COMPILER_DXC", "1") }; |
| 161 | std::string shaderNameStr = std::string("omm/Omm/libraries/omm-lib/shaders/") + shaderName; |
| 162 | return m_shaderFactory->CreateShader(shaderNameStr.c_str(), shaderEntryName, &defines, type); |
| 163 | }; |
| 164 | |
| 165 | omm::GpuBakeNvrhi::MessageCallback messageCb = [](omm::MessageSeverity severity, const char* message) { |
| 166 | donut::log::info("[OMM SDK]: %d %s", severity, message); |
| 167 | }; |
| 168 | |
| 169 | // Intialize the the internal baker, which records some buffer updates into a command list |
| 170 | nvrhi::CommandListHandle initCommandList = m_device->createCommandList(); |
| 171 | initCommandList->open(); |
| 172 | m_baker = std::make_unique<omm::GpuBakeNvrhi>(m_device, initCommandList, false /*debug*/, &provider, messageCb); |
| 173 | |
| 174 | // Submit baker init command list |
| 175 | initCommandList->close(); |
| 176 | m_device->executeCommandList(initCommandList); |
| 177 | // TODO: Do we really need to wait for device iddle here, or can we just subscribe a query to ensure resources are up by the time we use them? |
| 178 | m_device->waitForIdle(); |
| 179 | } |
| 180 | |
| 181 | OmmBuildQueue::~OmmBuildQueue() |
| 182 | { |
nothing calls this directly
no test coverage detected