Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoBufferObject.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20
21#pragma once
22
23#include <Inventor/SbBase.h>
24#include <Inventor/SbPImpl.h>
30#include <Inventor/STL/limits>
31#include <Inventor/renderer/RendererResourceMacro.h>
32
33#ifdef _WIN32
34#pragma warning(push)
35#pragma warning(disable:4251)
36#endif
37
38class SoDeviceContext;
40class SoCpuBufferObjectCache;
41
43
44
47#define SO_BUFFER_SIZE_ALL ((std::numeric_limits<size_t>::max)())
48
194{
196 SO_PIMPL_BASE_PUBLIC_HEADER(SoBufferObject)
197 RENDERER_RESOURCE(SoBufferObject);
198
199public:
200
203 {
207
213
219 };
220
227
234
246 virtual bool setSize( size_t size );
247
253 virtual size_t getSize() const;
254
265 virtual void* map(AccessMode accessMode, size_t offset = 0, size_t count = SO_BUFFER_SIZE_ALL);
266
270 virtual void unmap();
271
294 virtual void map( SoBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
295
305 virtual void unmap( SoBufferObject* bufferObject );
306
319 virtual void memcpy( SoBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
320
353 virtual void memset( void* value, size_t valueSize = 1, size_t offset = 0, size_t count = SO_BUFFER_SIZE_ALL );
354
359 virtual SoBufferObject* createInstance() const = 0;
360
364 virtual void clearInstance() = 0;
365
372
377
382
389
396
405 static SoCpuBufferObjectCache* getBufferObjectCache();
406
407private:
408
409 // should not be used elsewhere than in SoMemoryObject for compatibility purpose
410 void forceSize(size_t size);
411
412 // This function does a copy of the buffer to a CPU buffer object
413 virtual void copyToCpuBuffer( SoCpuBufferObject* targetBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
414
416 virtual SoBufferObject* clone() const;
417
418 // Set mapped buffer object info
419 void setMappedBufferObject(SoBufferObject* bufferObject, SoBufferObject::AccessMode accessMode,
420 size_t startPosition, size_t size);
421
422 // Clear mapped buffer object info
423 void clearMappedBufferObject();
424
429 uint64_t getModificationsCounter() const;
430
434 void incrementModificationsCounter() const;
435
436private:
437
445
450 virtual ~SoBufferObject();
451
456 void setDeviceContext(SoDeviceContext* context);
457
461 bool checkCopyConditions(size_t sourceSize, size_t sourceOffset,
462 size_t targetSize, size_t targetOffset, size_t copySize);
463
468 void touch();
469
470private:
471
478
479 // Instance of the class responsible for the cache of BufferObject.
480 static SoCpuBufferObjectCache* s_bufferObjectCache;
481
482 friend class SoCpuBufferObject;
483};
484
485
486#ifdef _WIN32
487#pragma warning(pop)
488#endif
#define SO_BUFFER_SIZE_ALL
Used to indicate that we want to use the whole buffer.
SO_PIMPL_BASE_PUBLIC_DECLARATION(SoImageDataAdapter)
#define SO_TYPED_CLASS_ABSTRACT_HEADER()
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
AccessMode
This enum provides the possible access modes for a mapped buffer object.
@ READ_ONLY
The target buffer initially has the same contents as the source buffer.
@ SET
The target buffer contents are initially undefined (although they may be the same as the source buffe...
@ READ_WRITE
The target buffer initially has the same contents as the source buffer and the source buffer will con...
virtual void map(SoBufferObject *targetBufferObject, AccessMode accessMode, size_t startPosition=0, size_t mappingSize=SO_BUFFER_SIZE_ALL)
Maps the current buffer object into the specified buffer object.
virtual void * map(AccessMode accessMode, size_t offset=0, size_t count=SO_BUFFER_SIZE_ALL)
Map the buffer to a system memory address and allows the mapping of a sub part of the buffer object i...
virtual size_t getSize() const
Returns the size, in bytes, of the buffer object.
virtual void unmap(SoBufferObject *bufferObject)
Unmap this buffer from the specified buffer object.
virtual void memcpy(SoBufferObject *sourceBufferObject, size_t destOffset=0, size_t sourceOffset=0, size_t copySize=SO_BUFFER_SIZE_ALL)
Copies data from the specified buffer object into this buffer object.
void unlockBuffer()
Unlocks the buffer object.
virtual void memset(void *value, size_t valueSize=1, size_t offset=0, size_t count=SO_BUFFER_SIZE_ALL)
This function sets the contents of (or a portion of) this buffer object to the specified value.
AccessMode getMappedBufferObjectAccessMode()
Returns the access mode used for the buffer mapping.
size_t getMappedBufferObjectSize() const
Returns the size of the mapped area in bytes.
size_t getMappedBufferObjectPosition() const
Returns the position in the source buffer mapped in this buffer.
virtual bool setSize(size_t size)
Sets the size in bytes of the buffer object.
SoDeviceContext * getContext() const
Returns the device context where this buffer is valid.
SoBufferObject * getMappedBufferObject() const
Returns a pointer to the buffer object which is mapped by the actual object.
virtual void unmap()
Unmaps the buffer from CPU address space.
static SoCpuBufferObjectCache * getBufferObjectCache()
Returns the cache manager object.
virtual SoBufferObject * createInstance() const =0
Create a new buffer with the same properties as the current one.
virtual void clearInstance()=0
Free the memory allocated by the buffer object.
void lockBuffer()
Locks the buffer against concurrent calls from different threads.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> CPU buffer objec...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Base class for ref-counted objects.
Base class for object storing runtime type information.
size_t size() const