MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / EnvironmentMapPass

Method EnvironmentMapPass

src/render/EnvironmentMapPass.cpp:48–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46using namespace donut::render;
47
48EnvironmentMapPass::EnvironmentMapPass(
49 nvrhi::IDevice* device,
50 std::shared_ptr<ShaderFactory> shaderFactory,
51 std::shared_ptr<CommonRenderPasses> commonPasses,
52 std::shared_ptr<FramebufferFactory> framebufferFactory,
53 const ICompositeView& compositeView,
54 nvrhi::ITexture* environmentMap)
55 : m_CommonPasses(commonPasses)
56 , m_FramebufferFactory(framebufferFactory)
57{
58 nvrhi::TextureDimension envMapDimension = environmentMap->getDesc().dimension;
59 bool isCubeMap = (envMapDimension == nvrhi::TextureDimension::TextureCube) ||
60 (envMapDimension == nvrhi::TextureDimension::TextureCubeArray);
61
62 std::vector<engine::ShaderMacro> PSMacros;
63 PSMacros.push_back(engine::ShaderMacro("LATLONG_TEXTURE", isCubeMap ? "0" : "1"));
64
65 m_PixelShader = shaderFactory->CreateAutoShader("donut/passes/environment_map_ps.hlsl", "main",
66 DONUT_MAKE_PLATFORM_SHADER(g_environment_map_ps), &PSMacros, nvrhi::ShaderType::Pixel);
67
68 nvrhi::BufferDesc constantBufferDesc;
69 constantBufferDesc.byteSize = sizeof(SkyConstants);
70 constantBufferDesc.debugName = "SkyConstants";
71 constantBufferDesc.isConstantBuffer = true;
72 constantBufferDesc.isVolatile = true;
73 constantBufferDesc.maxVersions = engine::c_MaxRenderPassConstantBufferVersions;
74 m_SkyCB = device->createBuffer(constantBufferDesc);
75
76 const IView* sampleView = compositeView.GetChildView(ViewType::PLANAR, 0);
77
78 {
79 nvrhi::BindingLayoutDesc layoutDesc;
80 layoutDesc.visibility = nvrhi::ShaderType::Pixel;
81 layoutDesc.bindings = {
82 nvrhi::BindingLayoutItem::VolatileConstantBuffer(0),
83 nvrhi::BindingLayoutItem::Texture_SRV(0),
84 nvrhi::BindingLayoutItem::Sampler(0)
85 };
86 m_RenderBindingLayout = device->createBindingLayout(layoutDesc);
87
88 nvrhi::BindingSetDesc bindingSetDesc;
89 bindingSetDesc.bindings = {
90 nvrhi::BindingSetItem::ConstantBuffer(0, m_SkyCB),
91 nvrhi::BindingSetItem::Texture_SRV(0, environmentMap),
92 nvrhi::BindingSetItem::Sampler(0, commonPasses->m_LinearWrapSampler)
93 };
94 m_RenderBindingSet = device->createBindingSet(bindingSetDesc, m_RenderBindingLayout);
95
96 nvrhi::GraphicsPipelineDesc pipelineDesc;
97 pipelineDesc.primType = nvrhi::PrimitiveType::TriangleStrip;
98 pipelineDesc.VS = sampleView->IsReverseDepth() ? m_CommonPasses->m_FullscreenVS : m_CommonPasses->m_FullscreenAtOneVS;
99 pipelineDesc.PS = m_PixelShader;
100 pipelineDesc.bindingLayouts = { m_RenderBindingLayout };
101
102 pipelineDesc.renderState.rasterState.setCullNone();
103 pipelineDesc.renderState.depthStencilState
104 .enableDepthTest()
105 .disableDepthWrite()

Callers

nothing calls this directly

Calls 7

ShaderMacroClass · 0.85
SamplerClass · 0.85
push_backMethod · 0.80
CreateAutoShaderMethod · 0.80
GetFramebufferInfoMethod · 0.80
GetChildViewMethod · 0.45
IsReverseDepthMethod · 0.45

Tested by

no test coverage detected