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); }
public void CreateDeviceObjects(GraphicsDevice gd, CommandList cl) { if (gd == null) { throw new ArgumentNullException(nameof(gd)); } if (cl == null) { throw new ArgumentNullException(nameof(cl)); } var factory = new DisposeCollectorResourceFactory(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("_Shared"), // CameraInfo / common data buffer ResourceLayoutHelper.UniformV("_Projection"), // Perspective Matrix ResourceLayoutHelper.UniformV("_View"), // View Matrix ResourceLayoutHelper.Texture("uPalette")); // PaletteTexture CommonResourceLayout = factory.CreateResourceLayout(commonLayoutDescription); CommonResourceLayout.Name = "RL_Common"; }