public virtual void CreateDeviceObjects(RenderContext rc) { ResourceFactory factory = rc.ResourceFactory; ProjectionMatrixBuffer = factory.CreateConstantBuffer(ShaderConstantType.Matrix4x4); ViewMatrixBuffer = factory.CreateConstantBuffer(ShaderConstantType.Matrix4x4); LightViewProjectionBuffer0 = factory.CreateConstantBuffer(ShaderConstantType.Matrix4x4); LightViewProjectionBuffer1 = factory.CreateConstantBuffer(ShaderConstantType.Matrix4x4); LightViewProjectionBuffer2 = factory.CreateConstantBuffer(ShaderConstantType.Matrix4x4); DepthLimitsBuffer = factory.CreateConstantBuffer(Unsafe.SizeOf <DepthCascadeLimits>()); LightInfoBuffer = factory.CreateConstantBuffer(Unsafe.SizeOf <DirectionalLightInfo>()); CameraInfoBuffer = factory.CreateConstantBuffer(Unsafe.SizeOf <CameraInfo>()); if (Camera != null) { UpdateCameraBuffers(); } PointLightsBuffer = factory.CreateConstantBuffer(Unsafe.SizeOf <PointLightsInfo.Blittable>()); PointLightsBuffer.SetData(new PointLightsInfo.Blittable()); NearShadowMapTexture = factory.CreateTexture(1, 2048, 2048, PixelFormat.R16_UInt, DeviceTextureCreateOptions.DepthStencil); NearShadowMapBinding = factory.CreateShaderTextureBinding(NearShadowMapTexture); NearShadowMapFramebuffer = factory.CreateFramebuffer(); NearShadowMapFramebuffer.DepthTexture = NearShadowMapTexture; MidShadowMapTexture = factory.CreateTexture(1, 2048, 2048, PixelFormat.R16_UInt, DeviceTextureCreateOptions.DepthStencil); MidShadowMapBinding = factory.CreateShaderTextureBinding(MidShadowMapTexture); MidShadowMapFramebuffer = factory.CreateFramebuffer(); MidShadowMapFramebuffer.DepthTexture = MidShadowMapTexture; FarShadowMapTexture = factory.CreateTexture(1, 4096, 4096, PixelFormat.R16_UInt, DeviceTextureCreateOptions.DepthStencil); FarShadowMapBinding = factory.CreateShaderTextureBinding(FarShadowMapTexture); FarShadowMapFramebuffer = factory.CreateFramebuffer(); FarShadowMapFramebuffer.DepthTexture = FarShadowMapTexture; }
public virtual void DestroyDeviceObjects() { ProjectionMatrixBuffer.Dispose(); ViewMatrixBuffer.Dispose(); LightInfoBuffer.Dispose(); LightViewProjectionBuffer0.Dispose(); LightViewProjectionBuffer1.Dispose(); LightViewProjectionBuffer2.Dispose(); DepthLimitsBuffer.Dispose(); CameraInfoBuffer.Dispose(); PointLightsBuffer.Dispose(); MainSceneColorTexture.Dispose(); MainSceneResolvedColorTexture.Dispose(); MainSceneResolvedColorView.Dispose(); MainSceneDepthTexture.Dispose(); MainSceneFramebuffer.Dispose(); MainSceneViewResourceSet.Dispose(); DuplicatorTarget0.Dispose(); DuplicatorTarget1.Dispose(); DuplicatorTargetView0.Dispose(); DuplicatorTargetView1.Dispose(); DuplicatorTargetSet0.Dispose(); DuplicatorTargetSet1.Dispose(); DuplicatorFramebuffer.Dispose(); TextureSamplerResourceLayout.Dispose(); ReflectionColorTexture.Dispose(); ReflectionDepthTexture.Dispose(); ReflectionColorView.Dispose(); ReflectionFramebuffer.Dispose(); ReflectionViewProjBuffer.Dispose(); MirrorClipPlaneBuffer.Dispose(); NoClipPlaneBuffer.Dispose(); ShadowMaps.DestroyDeviceObjects(); }
public virtual void DestroyDeviceObjects() { ProjectionMatrixBuffer.Dispose(); ViewMatrixBuffer.Dispose(); LightInfoBuffer.Dispose(); LightViewProjectionBuffer0.Dispose(); LightViewProjectionBuffer1.Dispose(); LightViewProjectionBuffer2.Dispose(); NearShadowMapBinding.Dispose(); NearShadowMapFramebuffer.Dispose(); NearShadowMapTexture.Dispose(); MidShadowMapBinding.Dispose(); MidShadowMapFramebuffer.Dispose(); MidShadowMapTexture.Dispose(); FarShadowMapBinding.Dispose(); FarShadowMapFramebuffer.Dispose(); FarShadowMapTexture.Dispose(); DepthLimitsBuffer.Dispose(); CameraInfoBuffer.Dispose(); PointLightsBuffer.Dispose(); }