GteDX11Buffer.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <Graphics/GteBuffer.h>
12 
13 namespace gte
14 {
15 
17 {
18 protected:
19  // Abstract base class.
20  DX11Buffer(Buffer const* buffer);
21 
22 public:
23  // Member access.
24  inline Buffer* GetBuffer() const;
25  inline ID3D11Buffer* GetDXBuffer() const;
26 
27  // Copy data from CPU to GPU via mapped memory. Buffers use only
28  // subresource 0, so the subresource index (sri) is not exposed.
29  virtual bool Update(ID3D11DeviceContext* context) override;
30  virtual bool CopyCpuToGpu(ID3D11DeviceContext* context) override;
31  virtual bool CopyGpuToCpu(ID3D11DeviceContext* context) override;
32 
33  // Copy from GPU to GPU directly. The first function copies the specified
34  // subresource. The second function copies all subresources.
35  virtual void CopyGpuToGpu(ID3D11DeviceContext* context, ID3D11Resource* target) override;
36 
37 private:
38  // Buffers use only subresource 0, so these overrides are stubbed out.
39  virtual bool Update(ID3D11DeviceContext* context, unsigned int sri) override;
40  virtual bool CopyCpuToGpu(ID3D11DeviceContext* context, unsigned int sri) override;
41  virtual bool CopyGpuToCpu(ID3D11DeviceContext* context, unsigned int sri) override;
42  virtual void CopyGpuToGpu(ID3D11DeviceContext* context, ID3D11Resource* target, unsigned int sri) override;
43 
44 protected:
45  // Support for creating staging buffers.
46  void CreateStaging(ID3D11Device* device, D3D11_BUFFER_DESC const& bf);
47 
48  // Dynamic constant buffers in D3D11.0 cannot be mapped using
49  // D3D11_MAP_WRITE_NO_OVERWRITE, but they can in D3D11.1. The MSDN
50  // web page for D3D11_MAP has a note about this and suggests how to
51  // test whether no-overwrite may be used by calling CheckFeatureSupport
52  // on the device with feature D3D11_FEATURE_D3D11_OPTIONS. Unfortunately,
53  // the documentation for D3D11_FEATURE_D3D11_OPTIONS may only be used
54  // for D3D11.1 and later. This mechanism fails on an NVIDIA Quadro
55  // K2200 (driver 362.13 and previous). A call to the device
56  // GetFeatureLevel returns D3D_FEATURE_LEVEL_11_0 but a call to
57  // CheckFeatureSupport shows that MapNoOverwriteOnDynamicConstantBuffer
58  // is 1 (so no-overwrite is supposed to be allowed). Unfortunately,
59  // this appears to cause problems in rendering. Worse is that our text
60  // rendering (TextEffect) uses dynamic vertex buffers and has strange
61  // behavior when using no-overwrite. All renders correctly with the
62  // discard mode. SO FOR NOW: mUpdateMapMode has default value
63  // D3D11_MAP_WRITE_DISCARD but is set to D3D11_MAP_WRITE_NO_OVERWRITE
64  // when the feature level is found to be D3D_FEATURE_LEVEL_11_1 or
65  // later.
66  D3D11_MAP mUpdateMapMode;
67 };
68 
70 {
71  return static_cast<Buffer*>(mGTObject);
72 }
73 
74 inline ID3D11Buffer* DX11Buffer::GetDXBuffer() const
75 {
76  return static_cast<ID3D11Buffer*>(mDXObject);
77 }
78 
79 }
ID3D11Buffer * GetDXBuffer() const
Definition: GteDX11Buffer.h:74
GLenum target
Definition: glcorearb.h:1662
Buffer * GetBuffer() const
Definition: GteDX11Buffer.h:69
GLuint buffer
Definition: glcorearb.h:655
D3D11_MAP mUpdateMapMode
Definition: GteDX11Buffer.h:66
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59