GteStructuredBuffer.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>
11 
12 namespace gte
13 {
14 
16 {
17 public:
18  // Construction.
19  StructuredBuffer(unsigned int numElements, size_t elementSize,
20  bool createStorage = true);
21 
22  enum GTE_IMPEXP CounterType
23  {
24  CT_NONE, // default,
26  CT_COUNTER
27  };
28 
29  CounterType GetCounterType() const;
30 
31  // Call one of these functions before binding the buffer to the engine.
32  // These will set the CounterType and set the usage to SHADER_OUTPUT.
33  void MakeAppendConsume();
34  void MakeCounter();
35 
36  // Let the GPU know whether or not to change its internal count when
37  // the buffer has a counter (CT_APPEND_CONSUME or CT_COUNTER). An input
38  // of 'true' means the GPU will let the counter keep its current value.
39  // This function is ignored when the buffer has counter type CT_NONE.
40  void SetKeepInternalCount(bool keepInternalCount);
41  bool GetKeepInternalCount() const;
42 
43  // To access the active number of elements maintained by the GPU for the
44  // CT_APPEND_CONSUME or CT_COUNTER buffers, you must call
45  // DX11Engine* engine = <your engine>;
46  // StructuredBuffer* buffer = <your buffer>;
47  // engine->GetNumActiveElements(buffer); // copy count from GPU to CPU
48  // int numElements = buffer->GetNumActiveElements();
49  // Also
50  // engine->CopyGpuToCpu(buffer);
51  // will fetch the buffer contents as well as the active number.
52 
53 protected:
54  CounterType mCounterType;
56 
57 public:
58  // For use by the Shader class for storing reflection information.
59  static int const shaderDataLookup = 2;
60 };
61 
62 }
CT_APPEND_CONSUME
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:01