GteDX11IndirectArgumentsBuffer.cpp
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 #include <GTEnginePCH.h>
10 using namespace gte;
11 
13  :
14  DX11Buffer(iabuffer)
15 {
16  // Specify the counter buffer description.
17  D3D11_BUFFER_DESC desc;
18  desc.ByteWidth = iabuffer->GetNumBytes();
19  desc.Usage = D3D11_USAGE_DEFAULT;
20  desc.BindFlags = D3D11_BIND_NONE;
21  desc.CPUAccessFlags = D3D11_CPU_ACCESS_NONE;
22  desc.MiscFlags = D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS;
23  desc.StructureByteStride = 0;
24 
25  // Create the counter buffer.
26  ID3D11Buffer* buffer = nullptr;
27  HRESULT hr;
28  if (iabuffer->GetData())
29  {
30  D3D11_SUBRESOURCE_DATA data;
31  data.pSysMem = iabuffer->GetData();
32  data.SysMemPitch = 0;
33  data.SysMemSlicePitch = 0;
34  hr = device->CreateBuffer(&desc, &data, &buffer);
35  }
36  else
37  {
38  hr = device->CreateBuffer(&desc, nullptr, &buffer);
39  }
40  CHECK_HR_RETURN_NONE("Failed to create indirect-arguments buffer");
41  mDXObject = buffer;
42 }
43 
44 std::shared_ptr<GEObject> DX11IndirectArgumentsBuffer::Create(void* device, GraphicsObject const* object)
45 {
46  if (object->GetType() == GT_INDIRECT_ARGUMENTS_BUFFER)
47  {
48  return std::make_shared<DX11IndirectArgumentsBuffer>(
49  reinterpret_cast<ID3D11Device*>(device),
50  static_cast<IndirectArgumentsBuffer const*>(object));
51  }
52 
53  LogError("Invalid object type.");
54  return nullptr;
55 }
#define CHECK_HR_RETURN_NONE(msg)
#define D3D11_BIND_NONE
GraphicsObjectType GetType() const
DX11IndirectArgumentsBuffer(ID3D11Device *device, IndirectArgumentsBuffer const *iabuffer)
GT_INDIRECT_ARGUMENTS_BUFFER
#define LogError(message)
Definition: GteLogger.h:92
GLboolean * data
Definition: glcorearb.h:126
static std::shared_ptr< GEObject > Create(void *device, GraphicsObject const *object)
ID3D11DeviceChild * mDXObject
unsigned int GetNumBytes() const
Definition: GteResource.h:116
char const * GetData() const
Definition: GteResource.h:151
#define D3D11_CPU_ACCESS_NONE
GLuint buffer
Definition: glcorearb.h:655


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