| 34 | namespace Falcor |
| 35 | { |
| 36 | BlitContext::BlitContext(Device* pDevice) |
| 37 | { |
| 38 | FALCOR_ASSERT(pDevice); |
| 39 | |
| 40 | // Init the blit data. |
| 41 | DefineList defines = { |
| 42 | {"SAMPLE_COUNT", "1"}, |
| 43 | {"COMPLEX_BLIT", "0"}, |
| 44 | {"SRC_INT", "0"}, |
| 45 | {"DST_INT", "0"}, |
| 46 | }; |
| 47 | ProgramDesc d; |
| 48 | d.addShaderLibrary("Core/API/BlitReduction.3d.slang").vsEntry("vsMain").psEntry("psMain"); |
| 49 | pPass = FullScreenPass::create(ref<Device>(pDevice), d, defines); |
| 50 | pPass->breakStrongReferenceToDevice(); |
| 51 | pFbo = Fbo::create(ref<Device>(pDevice)); |
| 52 | pFbo->breakStrongReferenceToDevice(); |
| 53 | FALCOR_ASSERT(pPass && pFbo); |
| 54 | |
| 55 | pBlitParamsBuffer = pPass->getVars()->getParameterBlock("BlitParamsCB"); |
| 56 | offsetVarOffset = pBlitParamsBuffer->getVariableOffset("gOffset"); |
| 57 | scaleVarOffset = pBlitParamsBuffer->getVariableOffset("gScale"); |
| 58 | prevSrcRectOffset = float2(-1.0f); |
| 59 | prevSrcReftScale = float2(-1.0f); |
| 60 | |
| 61 | Sampler::Desc desc; |
| 62 | desc.setAddressingMode(TextureAddressingMode::Clamp, TextureAddressingMode::Clamp, TextureAddressingMode::Clamp); |
| 63 | desc.setReductionMode(TextureReductionMode::Standard); |
| 64 | desc.setFilterMode(TextureFilteringMode::Linear, TextureFilteringMode::Linear, TextureFilteringMode::Point); |
| 65 | pLinearSampler = pDevice->createSampler(desc); |
| 66 | pLinearSampler->breakStrongReferenceToDevice(); |
| 67 | desc.setFilterMode(TextureFilteringMode::Point, TextureFilteringMode::Point, TextureFilteringMode::Point); |
| 68 | pPointSampler = pDevice->createSampler(desc); |
| 69 | pPointSampler->breakStrongReferenceToDevice(); |
| 70 | // Min reductions. |
| 71 | desc.setReductionMode(TextureReductionMode::Min); |
| 72 | desc.setFilterMode(TextureFilteringMode::Linear, TextureFilteringMode::Linear, TextureFilteringMode::Point); |
| 73 | pLinearMinSampler = pDevice->createSampler(desc); |
| 74 | pLinearMinSampler->breakStrongReferenceToDevice(); |
| 75 | desc.setFilterMode(TextureFilteringMode::Point, TextureFilteringMode::Point, TextureFilteringMode::Point); |
| 76 | pPointMinSampler = pDevice->createSampler(desc); |
| 77 | pPointMinSampler->breakStrongReferenceToDevice(); |
| 78 | // Max reductions. |
| 79 | desc.setReductionMode(TextureReductionMode::Max); |
| 80 | desc.setFilterMode(TextureFilteringMode::Linear, TextureFilteringMode::Linear, TextureFilteringMode::Point); |
| 81 | pLinearMaxSampler = pDevice->createSampler(desc); |
| 82 | pLinearMaxSampler->breakStrongReferenceToDevice(); |
| 83 | desc.setFilterMode(TextureFilteringMode::Point, TextureFilteringMode::Point, TextureFilteringMode::Point); |
| 84 | pPointMaxSampler = pDevice->createSampler(desc); |
| 85 | pPointMaxSampler->breakStrongReferenceToDevice(); |
| 86 | |
| 87 | const auto& pDefaultBlockReflection = pPass->getProgram()->getReflector()->getDefaultParameterBlock(); |
| 88 | texBindLoc = pDefaultBlockReflection->getResourceBinding("gTex"); |
| 89 | |
| 90 | // Complex blit parameters |
| 91 | |
| 92 | compTransVarOffset[0] = pBlitParamsBuffer->getVariableOffset("gCompTransformR"); |
| 93 | compTransVarOffset[1] = pBlitParamsBuffer->getVariableOffset("gCompTransformG"); |
nothing calls this directly
no test coverage detected