GteDX11Resource.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/GteResource.h>
12 
13 namespace gte
14 {
15 
17 {
18 public:
19  // Abstract base class.
20  virtual ~DX11Resource();
21 protected:
22  DX11Resource(Resource const* gtResource);
23 
24 public:
25  // Member access.
26  inline Resource* GetResource() const;
27  inline ID3D11Resource* GetDXResource() const;
28  inline ID3D11Resource* GetStagingResource() const;
29 
30  // Copy data from CPU to GPU via mapped memory for the specified
31  // subresource. The mapping is successful iff the returned struct's
32  // pData member is not null. The caller is responsible for using the
33  // row pitch and slice pitch correctly when writing to the memory.
34  D3D11_MAPPED_SUBRESOURCE MapForWrite(ID3D11DeviceContext* context, unsigned int sri);
35  void Unmap(ID3D11DeviceContext* context, unsigned int sri);
36 
37  // Copy from CPU (mGTObject memory) to GPU (mDXObject memory). The first
38  // function copies the specified subresource. The second function copies
39  // all subresources.
40  virtual bool Update(ID3D11DeviceContext* context, unsigned int sri) = 0;
41  virtual bool Update(ID3D11DeviceContext* context) = 0;
42 
43  // Copy from CPU to GPU using staging buffers. The first function copies
44  // the specified subresource. The second function copies all subresources.
45  virtual bool CopyCpuToGpu(ID3D11DeviceContext* context, unsigned int sri) = 0;
46  virtual bool CopyCpuToGpu(ID3D11DeviceContext* context) = 0;
47 
48  // Copy from GPU to CPU using staging buffers. The first function copies
49  // the specified subresource. The second function copies all subresources.
50  virtual bool CopyGpuToCpu(ID3D11DeviceContext* context, unsigned int sri) = 0;
51  virtual bool CopyGpuToCpu(ID3D11DeviceContext* context) = 0;
52 
53  // Copy from GPU to GPU directly. The first function copies the specified
54  // subresource. The second function copies all subresources.
55  virtual void CopyGpuToGpu(ID3D11DeviceContext* context,
56  ID3D11Resource* target, unsigned int sri) = 0;
57  virtual void CopyGpuToGpu(ID3D11DeviceContext* context,
58  ID3D11Resource* target) = 0;
59 
60  // Support for the DX11 debug layer; see comments in the file
61  // GteDX11GraphicsObject.h about usage.
62  virtual void SetName(std::string const& name) override;
63 
64 protected:
65  // Support for copying between CPU and GPU.
66  bool PreparedForCopy(D3D11_CPU_ACCESS_FLAG access) const;
67 
68  // A staging buffer is used for copying between CPU and GPU memory.
69  ID3D11Resource* mStaging;
70 
71  // Mapping from Resource::CopyType to D3D11_CPU_ACCESS_FLAG.
72  static UINT const msStagingAccess[];
73 };
74 
76 {
77  return static_cast<Resource*>(mGTObject);
78 }
79 
80 inline ID3D11Resource* DX11Resource::GetDXResource() const
81 {
82  return static_cast<ID3D11Resource*>(mDXObject);
83 }
84 
85 inline ID3D11Resource* DX11Resource::GetStagingResource() const
86 {
87  return mStaging;
88 }
89 
90 }
GLuint const GLchar * name
Definition: glcorearb.h:781
GLenum target
Definition: glcorearb.h:1662
ID3D11Resource * mStaging
GLuint GLint GLboolean GLint GLenum access
Definition: glcorearb.h:2217
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
ID3D11Resource * GetDXResource() const
ID3D11Resource * GetStagingResource() const
typedef UINT(WINAPI *PFNWGLGETGPUIDSAMDPROC)(UINT maxCount
Resource * GetResource() const
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


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