| 56 | } |
| 57 | |
| 58 | void TextureAnalyzer::analyze( |
| 59 | RenderContext* pRenderContext, |
| 60 | const ref<Texture> pInput, |
| 61 | uint32_t mipLevel, |
| 62 | uint32_t arraySlice, |
| 63 | ref<Buffer> pResult, |
| 64 | uint64_t resultOffset, |
| 65 | bool clearResult |
| 66 | ) |
| 67 | { |
| 68 | FALCOR_ASSERT(pRenderContext && pInput); |
| 69 | FALCOR_ASSERT(pResult && resultOffset + getResultSize() <= pResult->getSize()); |
| 70 | FALCOR_ASSERT(resultOffset < std::numeric_limits<uint32_t>::max()); |
| 71 | |
| 72 | checkFormatSupport(pInput, mipLevel, arraySlice); |
| 73 | |
| 74 | if (clearResult) |
| 75 | { |
| 76 | clear(pRenderContext, pResult, resultOffset, 1); |
| 77 | } |
| 78 | |
| 79 | auto pSRV = pInput->getSRV(mipLevel, 1, arraySlice, 1); |
| 80 | FALCOR_ASSERT(pSRV); |
| 81 | |
| 82 | uint2 dim = {pInput->getWidth(mipLevel), pInput->getHeight(mipLevel)}; |
| 83 | FALCOR_ASSERT(dim.x > 0 && dim.y > 0); |
| 84 | |
| 85 | // Bind resources. |
| 86 | auto var = mpAnalyzePass->getRootVar()["gTextureAnalyzer"]; |
| 87 | var["input"].setSrv(pSRV); |
| 88 | var["result"] = pResult; |
| 89 | var["resultOffset"] = (uint32_t)resultOffset; |
| 90 | var["inputDim"] = dim; |
| 91 | |
| 92 | mpAnalyzePass->execute(pRenderContext, uint3(dim, 1)); |
| 93 | } |
| 94 | |
| 95 | void TextureAnalyzer::analyze(RenderContext* pRenderContext, const std::vector<ref<Texture>>& inputs, ref<Buffer> pResult, bool clearResult) |
| 96 | { |