| 147 | }; |
| 148 | |
| 149 | class VariableRateShading : public app::ApplicationBase |
| 150 | { |
| 151 | private: |
| 152 | std::shared_ptr<vfs::RootFileSystem> m_RootFS; |
| 153 | |
| 154 | nvrhi::ShaderLibraryHandle m_ShaderLibrary; |
| 155 | nvrhi::CommandListHandle m_CommandList; |
| 156 | |
| 157 | nvrhi::BufferHandle m_ConstantBuffer; |
| 158 | |
| 159 | std::shared_ptr<engine::ShaderFactory> m_ShaderFactory; |
| 160 | std::unique_ptr<engine::Scene> m_Scene; |
| 161 | std::unique_ptr<render::ForwardShadingPass> m_ForwardPass; |
| 162 | std::unique_ptr<render::TemporalAntiAliasingPass> m_temporalPass; |
| 163 | std::unique_ptr<RenderTargets> m_RenderTargets; |
| 164 | app::FirstPersonCamera m_Camera; |
| 165 | engine::PlanarView m_View; |
| 166 | std::shared_ptr<engine::DirectionalLight> m_SunLight; |
| 167 | std::unique_ptr<render::InstancedOpaqueDrawStrategy> m_OpaqueDrawStrategy; |
| 168 | std::unique_ptr<render::TransparentDrawStrategy> m_TransparentDrawStrategy; |
| 169 | std::unique_ptr<engine::BindingCache> m_BindingCache; |
| 170 | |
| 171 | nvrhi::ShaderHandle m_shadingRateSurfaceShader; |
| 172 | nvrhi::ComputePipelineHandle m_Pipeline; |
| 173 | nvrhi::BindingLayoutHandle m_bindingLayout; |
| 174 | nvrhi::BindingSetHandle m_bindingSet; |
| 175 | nvrhi::TextureHandle m_shadingRateSurface; |
| 176 | uint m_vrsTileSize; |
| 177 | |
| 178 | engine::PlanarView m_ViewPrevious; |
| 179 | bool m_PreviousViewsValid = false; |
| 180 | |
| 181 | bool m_UseRawD3D12 = false; |
| 182 | |
| 183 | public: |
| 184 | using ApplicationBase::ApplicationBase; |
| 185 | |
| 186 | bool Init(bool useRawD3D12) |
| 187 | { |
| 188 | m_UseRawD3D12 = useRawD3D12; |
| 189 | |
| 190 | std::filesystem::path sceneFileName = app::GetDirectoryWithExecutable().parent_path() / "media/glTF-Sample-Assets/Models/Sponza/glTF/Sponza.gltf"; |
| 191 | std::filesystem::path frameworkShaderPath = app::GetDirectoryWithExecutable() / "shaders/framework" / app::GetShaderTypeName(GetDevice()->getGraphicsAPI()); |
| 192 | std::filesystem::path appShaderPath = app::GetDirectoryWithExecutable() / "shaders/variable_shading" / app::GetShaderTypeName(GetDevice()->getGraphicsAPI()); |
| 193 | |
| 194 | m_RootFS = std::make_shared<vfs::RootFileSystem>(); |
| 195 | m_RootFS->mount("/shaders/donut", frameworkShaderPath); |
| 196 | m_RootFS->mount("/shaders/app", appShaderPath); |
| 197 | |
| 198 | m_ShaderFactory = std::make_shared<engine::ShaderFactory>(GetDevice(), m_RootFS, "/shaders"); |
| 199 | m_CommonPasses = std::make_shared<engine::CommonRenderPasses>(GetDevice(), m_ShaderFactory); |
| 200 | m_BindingCache = std::make_unique<engine::BindingCache>(GetDevice()); |
| 201 | |
| 202 | m_shadingRateSurfaceShader = m_ShaderFactory->CreateShader("/shaders/app/shaders.hlsl", "main_cs", nullptr, nvrhi::ShaderType::Compute); |
| 203 | if (!m_shadingRateSurfaceShader) |
| 204 | { |
| 205 | return false; |
| 206 | } |
nothing calls this directly
no outgoing calls
no test coverage detected