예제 #1
0
        public void CreateDeviceObjects(GraphicsDevice gd, CommandList cl)
        {
            var factory = new DisposingResourceFactoryFacade(gd.ResourceFactory, _disposer);

            DeviceBuffer MakeBuffer(uint size, string name)
            {
                var buffer = factory.CreateBuffer(
                    new BufferDescription(size, BufferUsage.UniformBuffer | BufferUsage.Dynamic));

                buffer.Name = name;
                return(buffer);
            }

            ProjectionMatrixBuffer = MakeBuffer(64, "M_Projection");
            ModelViewMatrixBuffer  = MakeBuffer(64, "M_View");
            IdentityMatrixBuffer   = MakeBuffer(64, "M_Id");
            DepthLimitsBuffer      = MakeBuffer((uint)Unsafe.SizeOf <DepthCascadeLimits>(), "B_DepthLimits");
            CameraInfoBuffer       = MakeBuffer((uint)Unsafe.SizeOf <CameraInfo>(), "B_CameraInfo");

            cl.UpdateBuffer(IdentityMatrixBuffer, 0, Matrix4x4.Identity);

            var commonLayoutDescription = new ResourceLayoutDescription(
                ResourceLayoutHelper.Uniform("vdspv_1_0"),  // CameraInfo / common data buffer
                ResourceLayoutHelper.UniformV("vdspv_1_1"), // Perspective Matrix
                ResourceLayoutHelper.UniformV("vdspv_1_2"), // View Matrix
                ResourceLayoutHelper.Texture("vdspv_1_3")); // PaletteTexture

            CommonResourceLayout      = factory.CreateResourceLayout(commonLayoutDescription);
            CommonResourceLayout.Name = "RL_Common";

            _windowSized = new WindowSizedSceneContext(gd, MainSceneSampleCount);
            _disposer.Add(_windowSized, CommonResourceLayout);
        }
예제 #2
0
 public void RecreateWindowSizedResources(GraphicsDevice graphicsDevice)
 {
     _disposer.Remove(_windowSized);
     _windowSized.Dispose();
     _windowSized = new WindowSizedSceneContext(graphicsDevice, MainSceneSampleCount);
     _disposer.Add(_windowSized);
 }