| 14 | #include <libntc/shaders/Bindings.h> |
| 15 | |
| 16 | bool GraphicsImageDifferencePass::Init() |
| 17 | { |
| 18 | // Create the binding layout |
| 19 | nvrhi::VulkanBindingOffsets vulkanBindingOffsets; |
| 20 | vulkanBindingOffsets |
| 21 | .setConstantBufferOffset(0) |
| 22 | .setSamplerOffset(0) |
| 23 | .setShaderResourceOffset(0) |
| 24 | .setUnorderedAccessViewOffset(0); |
| 25 | |
| 26 | auto bindingLayoutDesc = nvrhi::BindingLayoutDesc() |
| 27 | .setVisibility(nvrhi::ShaderType::Compute) |
| 28 | .setBindingOffsets(vulkanBindingOffsets) |
| 29 | .addItem(nvrhi::BindingLayoutItem::VolatileConstantBuffer(NTC_BINDING_IMAGE_DIFF_CONSTANT_BUFFER)) |
| 30 | .addItem(nvrhi::BindingLayoutItem::Texture_SRV(NTC_BINDING_IMAGE_DIFF_INPUT_TEXTURE_A)) |
| 31 | .addItem(nvrhi::BindingLayoutItem::Texture_SRV(NTC_BINDING_IMAGE_DIFF_INPUT_TEXTURE_B)) |
| 32 | .addItem(nvrhi::BindingLayoutItem::RawBuffer_UAV(NTC_BINDING_IMAGE_DIFF_OUTPUT_BUFFER)); |
| 33 | |
| 34 | m_bindingLayout = m_device->createBindingLayout(bindingLayoutDesc); |
| 35 | if (!m_bindingLayout) |
| 36 | return false; |
| 37 | |
| 38 | // Create the results buffer |
| 39 | auto resultBufferDesc = nvrhi::BufferDesc() |
| 40 | .setByteSize(BytesPerQuery * m_maxQueries) |
| 41 | .setDebugName("Compare Results") |
| 42 | .setCanHaveRawViews(true) |
| 43 | .setCanHaveUAVs(true) |
| 44 | .setInitialState(nvrhi::ResourceStates::UnorderedAccess) |
| 45 | .setKeepInitialState(true); |
| 46 | |
| 47 | m_outputBuffer = m_device->createBuffer(resultBufferDesc); |
| 48 | if (!m_outputBuffer) |
| 49 | return false; |
| 50 | |
| 51 | // Create the staging/readback buffer |
| 52 | auto stagingBufferDesc = nvrhi::BufferDesc() |
| 53 | .setByteSize(resultBufferDesc.byteSize) |
| 54 | .setDebugName("Compare Staging") |
| 55 | .setCpuAccess(nvrhi::CpuAccessMode::Read) |
| 56 | .setInitialState(nvrhi::ResourceStates::CopyDest) |
| 57 | .setKeepInitialState(true); |
| 58 | |
| 59 | m_stagingBuffer = m_device->createBuffer(stagingBufferDesc); |
| 60 | if (!m_stagingBuffer) |
| 61 | return false; |
| 62 | |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | uint32_t GraphicsImageDifferencePass::GetOffsetForQuery(uint32_t queryIndex) const |
| 67 | { |
nothing calls this directly
no outgoing calls
no test coverage detected