public BasicSceneRenderer(GraphicsDevice device) { _device = device; _rtvs = _device.CreateDescriptorHeap(DescriptorHeapType.RenderTargetView, 1); _dsvs = _device.CreateDescriptorHeap(DescriptorHeapType.RenderTargetView, 1); _textureHandle = _device.AllocateResourceDescriptors(2); _texturedObjects = ModelLoader.LoadGl_Old("Assets/Gltf/Handgun_NoTangent.gltf"); //_texturedObjects = new[] { GeometryGenerator.CreateCube(0.5f) }; var texture = TextureLoader.LoadTextureDesc("Assets/Textures/handgun_c.dds"); var normals = TextureLoader.LoadTextureDesc("Assets/Textures/handgun_n.dds"); _vertexBuffer = new Buffer[_texturedObjects.Length]; _indexBuffer = new Buffer[_texturedObjects.Length]; using (var list = _device.BeginUploadContext()) { for (var i = 0; i < _texturedObjects.Length; i++) { _vertexBuffer[i] = list.UploadBuffer(_texturedObjects[i].Vertices); _vertexBuffer[i].SetName("VertexBuffer"); _indexBuffer[i] = list.UploadBuffer(_texturedObjects[i].Indices); _indexBuffer[i].SetName("IndexBuffer"); } _texture = list.UploadTexture(texture); _texture.SetName("Gun texture"); } //list.UploadTexture(normals.Data.Span, normals.SubresourceData.Span, normals.Desc, ResourceState.PixelShaderResource, out _normals); //_normals.SetName("Gun normals"); _device.CreateShaderResourceView(_texture, _textureHandle[0]); //_normalHandle = _device.CreateShaderResourceView(_normals); _objectConstants = new ObjectConstants[_texturedObjects.Length]; _obj = _device.Allocator.AllocateBuffer(MathHelpers.AlignUp(sizeof(ObjectConstants), 256) * _texturedObjects.Length, MemoryAccess.CpuUpload); _obj.SetName("ObjectConstants buffer"); _frame = _device.Allocator.AllocateBuffer(sizeof(FrameConstants), MemoryAccess.CpuUpload); _frame.SetName("FrameConstants buffer"); _light = _device.Allocator.AllocateBuffer(sizeof(LightConstants), MemoryAccess.CpuUpload); _light.SetName("LightConstants buffer"); CreatePipelines(); InitializeConstants(); }