H3D API  2.4.1
ShaderStorageBuffer.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __SHADERSTORAGEBUFFER_H__
30 #define __SHADERSTORAGEBUFFER_H__
31 
32 #include <H3D/ShaderChildNode.h>
33 #include <H3D/SFInt32.h>
34 #include <H3D/SFString.h>
35 
36 namespace H3D {
37 
49  class H3DAPI_API ShaderStorageBuffer :
50  public ShaderChildNode {
51  public:
52 
54  ShaderStorageBuffer( Inst< DisplayList > _displayList = 0,
55  Inst< SFNode > _metadata = 0,
56  Inst< SFInt32 > _width = 0,
57  Inst< SFInt32 > _height = 0,
58  Inst< SFInt32 > _depth = 0,
59  Inst< SFInt32 > _dataSize = 0,
60  Inst< SFString > _storageName = 0
61  );
62 
63 
64 
66  virtual void preRender( unsigned int program );
67 
70  virtual void render ( );
71 
72 
74  virtual void prepareStorageBuffer ( );
75 
76 
77  virtual int getStorageBlockBinding ( ){
78  return storage_block_binding;
79  }
80 
81  virtual void initialize ( );
82 
84 
85  // width, height and depth is used to set the size
86  // of the buffer data. It is actually just one value, as shader storage
87  // buffer is used in shader, to separate it into three dimension
88  // will make it more intuitive
89 
93  H3DUniquePtr<SFInt32> width;
94 
98  H3DUniquePtr<SFInt32> height;
99 
103  H3DUniquePtr<SFInt32> depth;
104 
109  H3DUniquePtr<SFInt32> dataSize;
110 
114  H3DUniquePtr<SFString> storageName;
115 
118 
119  protected:
120 
122  unsigned int program_handle;
123 
126 
129  unsigned int storage_block_index;
130 
136 
137  // collection of all the current storage block binding points already used,
138  // it will be used to help generate non-identical block binding id
139  static set<size_t> global_block_bindings;
140  static H3DUtil::MutexLock global_block_bindings_lock;
141  static size_t max_block_bindings;
142  static int generateShaderStorageBinding ( );
143  static void deleteShaderStorageBinding ( int binding );
144  // maximum ssbo size supported
145  H3DUTIL_INT64 max_ssbo_size;
146  H3DUniquePtr<Field> rebuildBuffer;
147  };
148 }
149 
150 #endif
Contains the SFInt32 field class.
Contains the SFString field class.
Header file for ShaderChildNode.
This is the base node type for the child nodes of the ComposedShader node.
Definition: ShaderChildNode.h:44
This node provide a buffer object for OpenGL shader program to write into and read from.
Definition: ShaderStorageBuffer.h:50
H3DUniquePtr< SFInt32 > dataSize
data size of the structure used for shader storage buffer the metric is bytes Access type: inputOutpu...
Definition: ShaderStorageBuffer.h:109
H3DUniquePtr< SFInt32 > width
horizontal dimension for the data Access type: inputOutput Default value: 512
Definition: ShaderStorageBuffer.h:93
unsigned int storage_block_index
the active block index assigned by the shader, will have valid value only after the shader program ge...
Definition: ShaderStorageBuffer.h:129
int buffer_id
buffer id, generated by openGL
Definition: ShaderStorageBuffer.h:125
int storage_block_binding
the block binding point for shader storage buffer in openGL context its value must be less than the M...
Definition: ShaderStorageBuffer.h:135
H3DUniquePtr< SFInt32 > height
vertical dimension for the data Access type: inputOutput Default value: 512
Definition: ShaderStorageBuffer.h:98
H3DUniquePtr< SFInt32 > depth
layers for the data Access type: inputOutput Default value: 16
Definition: ShaderStorageBuffer.h:103
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: ShaderStorageBuffer.h:117
unsigned int program_handle
shader program that this shader storage buffer will be attached
Definition: ShaderStorageBuffer.h:122
H3DUniquePtr< SFString > storageName
storage buffer name used in shader by default, it will use the node name if not being set Access type...
Definition: ShaderStorageBuffer.h:114
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194