Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::GPUTexture Class Referenceabstract

A data structure for 1/2/3D and cube texture mapping. Also has optional render-to-texture functionality. More...

#include <mitsuba/hw/gputexture.h>

+ Inheritance diagram for mitsuba::GPUTexture:

Public Types

enum  ETextureType { ETexture1D = 0, ETexture2D, ETexture3D, ETextureCubeMap }
 Available texture types. More...
 
enum  EFrameBufferType { ENone = 0x00, EColorBuffer = 0x01, EDepthBuffer = 0x02, EColorAndDepthBuffer = 0x03 }
 If the texture type is set to EFrameBuffer, the configuration must be one of the following constants. More...
 
enum  EComponentFormat {
  EUInt8, EUInt16, EUInt32, EFloat16,
  EFloat32, EFloat64
}
 Supported per-component data formats. More...
 
enum  EPixelFormat {
  EDepth = 0, ELuminance, ELuminanceAlpha, ERGB,
  ERGBA
}
 Supported pixel format types. More...
 
enum  ETexturePosition {
  EDefaultPosition = 0, ECubeMapPositiveX = 0, ECubeMapNegativeX, ECubeMapPositiveY,
  ECubeMapNegativeY, ECubeMapPositiveZ, ECubeMapNegativeZ, ELastPosition
}
 A texture has one more slots into which bitmaps can be placed. More...
 
enum  EWrapType {
  EClamp = 0, EClampToEdge, EClampToBorder, ERepeat,
  EMirror
}
 Texture wrapping mode when texture coordinates exit the [0, 1] range. More...
 
enum  EFilterType { ENearest = 0, ELinear, EMipMapNearest, EMipMapLinear }
 The interpolation filter determines which texture pixels are considered when shading a fragment. More...
 
enum  EDepthMode { ENormal, ECompare }
 When this texture contains a depth buffer, the following modes control the read behavior of the associated texture unit. 'ENormal' means that texture values are returned as with any other texture, whereas 'ECompare' causes a depth comparison to take place (this is the default). More...
 

Public Member Functions

 GPUTexture (const std::string &name, Bitmap *bitmap)
 Construct a new texture. More...
 
void setName (const std::string &name)
 Set the texture name. More...
 
const std::string & getName () const
 Get the texture name. More...
 
void setType (ETextureType textureType)
 Set the texture type. More...
 
ETextureType getType () const
 Return the texture type. More...
 
void setPixelFormat (EPixelFormat fmt)
 Set the pixel format of this texture. More...
 
EPixelFormat getPixelFormat () const
 Return the pixel format of this texture. More...
 
void setComponentFormat (EComponentFormat fmt)
 Set the component format of this texture. More...
 
EComponentFormat getComponentFormat () const
 Return the component format of this texture. More...
 
void setFrameBufferType (EFrameBufferType frameBufferType)
 Set the framebuffer type (applies only if type==EFrameBuffer) More...
 
EFrameBufferType getFrameBufferType () const
 Return the framebuffer type (applies only if type==EFrameBuffer) More...
 
void setFilterType (EFilterType filterType)
 Set the filter type. More...
 
EFilterType getFilterType () const
 Return the filter type. More...
 
void setWrapType (EWrapType wrapType)
 Set the wrap type. More...
 
void setWrapTypeU (EWrapType wrapType)
 Set the wrap type along the U axis. More...
 
EWrapType getWrapTypeU ()
 Return the wrap type along the U axis. More...
 
void setWrapTypeV (EWrapType wrapType)
 Set the wrap type along the V axis. More...
 
EWrapType getWrapTypeV ()
 Return the wrap type along the V axis. More...
 
Point3i getSize () const
 Return the size in pixels. More...
 
void setSize (const Point3i &size)
 Set the size in pixels. More...
 
Float getMaxAnisotropy () const
 Get the maximal anisotropy. More...
 
void setMaxAnisotropy (Float maxAnisotropy)
 Set the maximal anisotropy. More...
 
bool isMipMapped () const
 Return whether mipmapping is enabled. More...
 
void setMipMapped (bool mipMapped)
 Define whether mipmapping is enabled. More...
 
EDepthMode getDepthMode () const
 Return the depth map read mode. More...
 
void setDepthMode (EDepthMode mode)
 Set the depth map read mode. More...
 
void setBitmap (unsigned int slot, Bitmap *bitmap)
 Store a bitmap in a bitmap slot. More...
 
BitmapgetBitmap (unsigned int slot=EDefaultPosition)
 Retrieve a bitmap from the given slot. More...
 
const BitmapgetBitmap (unsigned int slot=EDefaultPosition) const
 Retrieve a bitmap from the given slot. More...
 
int getBitmapCount () const
 Return the number of stored bitmaps. More...
 
virtual void init ()=0
 Upload the texture. More...
 
void release ()
 Dereference the CPU bitmap associated with the texture. More...
 
void initAndRelease ()
 Run init, followed by release. More...
 
virtual void refresh ()=0
 Refresh (re-upload) the texture. More...
 
virtual void refresh (const Point2i &offset, const Vector2i &size)=0
 Refresh (re-upload) a subregion of the texture. More...
 
virtual void cleanup ()=0
 Free the texture from GPU memory. More...
 
virtual void bind (int textureUnit=0, int textureIndex=0) const =0
 Bind the texture and enable texturing. More...
 
virtual void unbind () const =0
 Unbind the texture and disable texturing. More...
 
virtual void download (Bitmap *bitmap=NULL)=0
 
virtual void activateTarget ()=0
 Activate the render target. More...
 
virtual void activateSide (int side)=0
 Activate a certain face of a cube map as render target. More...
 
virtual void setTargetRegion (const Point2i &offset, const Vector2i &size)=0
 Restrict rendering to a sub-region of the texture. More...
 
virtual void releaseTarget ()=0
 Deactivate the render target. More...
 
const std::set< int > & getTextureUnits () const
 Return the texture units, to which this texture is currently bound. More...
 
void setSampleCount (int samples)
 Set the number of samples (for multisample color render targets) More...
 
int getSampleCount () const
 Return the number of samples (for multisample color render targets) More...
 
void setBorderColor (const Color3 &borderColor)
 Set the border color (applicable if wrapMode=EClamp/EClampToBorder) More...
 
const Color3getBorderColor () const
 Return the border color. More...
 
virtual void blit (GPUTexture *target, int what) const =0
 Blit a render buffer into another render buffer. More...
 
virtual void blit (GPUTexture *target, int what, const Point2i &sourceOffset, const Vector2i &sourceSize, const Point2i &destOffset, const Vector2i &destSize) const =0
 Blit a render buffer into another render buffer. More...
 
virtual void clear ()=0
 Clear (assuming that this is a render buffer) More...
 
virtual Color3 getPixel (int x, int y) const =0
 Assuming that this is a 2D RGB framebuffer, read a single pixel from the GPU. More...
 
std::string toString () const
 Return a string representation. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

virtual ~GPUTexture ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

std::string m_name
 
ETextureType m_type
 
EPixelFormat m_pixelFormat
 
EComponentFormat m_componentFormat
 
EFilterType m_filterType
 
EWrapType m_wrapTypeU
 
EWrapType m_wrapTypeV
 
EFrameBufferType m_fbType
 
EDepthMode m_depthMode
 
bool m_mipmapped
 
PrimitiveThreadLocal< std::set
< int > > 
m_textureUnits
 
Float m_maxAnisotropy
 
int m_samples
 
std::vector< Bitmap * > m_bitmaps
 
Point3i m_size
 
Color3 m_borderColor
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 

Detailed Description

A data structure for 1/2/3D and cube texture mapping. Also has optional render-to-texture functionality.

Member Enumeration Documentation

Supported per-component data formats.

Enumerator
EUInt8 

8-bit unsigned integer (uint8_t) component encoding

EUInt16 

16-bit unsigned integer (uint16_t) component encoding

EUInt32 

32-bit unsigned integer (uint32_t) component encoding

EFloat16 

16-bit floating point (half) HDR component encoding

EFloat32 

32-bit floating point (float) HDR component encoding

EFloat64 

64-bit floating point (float) HDR component encoding

When this texture contains a depth buffer, the following modes control the read behavior of the associated texture unit. 'ENormal' means that texture values are returned as with any other texture, whereas 'ECompare' causes a depth comparison to take place (this is the default).

Enumerator
ENormal 
ECompare 

The interpolation filter determines which texture pixels are considered when shading a fragment.

Enumerator
ENearest 

Use the color value of the closest pixel.

ELinear 

Use 4 surrounding pixels and weigh them.

EMipMapNearest 

Blend the color values of the closest matching mipmaps and use nearest filtering

EMipMapLinear 

Blend the color values of the closest matching mipmaps and use linear filtering (aka. bilinear)

If the texture type is set to EFrameBuffer, the configuration must be one of the following constants.

Enumerator
ENone 

This is not a framebuffer.

EColorBuffer 

Color framebuffer (including an internal depth buffer that cannot be accessed as a texture)

EDepthBuffer 

Depth-only framebuffer (e.g. for shadow mapping)

EColorAndDepthBuffer 

Color and texture framebuffer (both exposed as textures)

Supported pixel format types.

Enumerator
EDepth 

Single-channel depth map.

ELuminance 

Single-channel luminance bitmap.

ELuminanceAlpha 

Two-channel luminance + alpha bitmap.

ERGB 

RGB bitmap.

ERGBA 

RGB bitmap + alpha channel.

A texture has one more slots into which bitmaps can be placed.

Enumerator
EDefaultPosition 

Default slot for 1,2,3D textures.

ECubeMapPositiveX 

Cube map: +X plane, Right.

ECubeMapNegativeX 

Cube map: -X plane, Left.

ECubeMapPositiveY 

Cube map: +Y plane, Top.

ECubeMapNegativeY 

Cube map: -Y plane, Bottom.

ECubeMapPositiveZ 

Cube map: +Z plane, Front.

ECubeMapNegativeZ 

Cube map: -Z plane, Back.

ELastPosition 

Available texture types.

Enumerator
ETexture1D 

1-D texture, useful for the storage of pre-calculated functions in conjunction with pixel shaders. Needs 1D texture coordinates

ETexture2D 

Default 2D texture format, needs 2D texture coordinates.

ETexture3D 

3D volume texture format, needs 3D texture coordinates

ETextureCubeMap 

3D cube map texture format, needs 3D texture coordinates

Texture wrapping mode when texture coordinates exit the [0, 1] range.

Enumerator
EClamp 

Clamp the coordinates to [0, 1].

EClampToEdge 

Similar to EClamp, but prevents mixing at the edges.

EClampToBorder 

Similar to EClamp.

ERepeat 

Modulo 1 operation (default)

EMirror 

Mirror the coordinates at the edges.

Constructor & Destructor Documentation

mitsuba::GPUTexture::GPUTexture ( const std::string &  name,
Bitmap bitmap 
)

Construct a new texture.

If bitmap is non-NULL, the texture type, format will be automatically set

Parameters
nameA human-readable name (for debugging)
bitmapAn bitmap to be put into the first slot. A NULL value will be ignored.
virtual mitsuba::GPUTexture::~GPUTexture ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

virtual void mitsuba::GPUTexture::activateSide ( int  side)
pure virtual

Activate a certain face of a cube map as render target.

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::activateTarget ( )
pure virtual

Activate the render target.

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::bind ( int  textureUnit = 0,
int  textureIndex = 0 
) const
pure virtual

Bind the texture and enable texturing.

Parameters
textureUnitSpecifies the unit to which this texture should be bound
textureIndexWhen this texture has multiple sub-textures (e.g. a color and depth map in the case of a EColorAndDepthBuffer texture), this parameter specifies the one to be bound

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::blit ( GPUTexture target,
int  what 
) const
pure virtual

Blit a render buffer into another render buffer.

Parameters
targetSpecifies the target render buffer
whatA bitwise-OR of the components in EFrameBufferType to copy

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::blit ( GPUTexture target,
int  what,
const Point2i sourceOffset,
const Vector2i sourceSize,
const Point2i destOffset,
const Vector2i destSize 
) const
pure virtual

Blit a render buffer into another render buffer.

Parameters
targetSpecifies the target render buffer (or NULL for the framebuffer)
whatA bitwise-OR of the components in EFrameBufferType to copy
sourceOffsetOffset in the source render buffer
sourceOffsetSize of the region to be copied from the source render buffer
destOffsetOffset in the destination render buffer
destOffsetSize of the region to be copied into the dest destination buffer

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::cleanup ( )
pure virtual

Free the texture from GPU memory.

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::clear ( )
pure virtual

Clear (assuming that this is a render buffer)

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::download ( Bitmap bitmap = NULL)
pure virtual

Download the texture (only for render target textures). When the 'bitmap' parameter is NULL, the destination is the internal bitmap given by getTexture(0)

Implemented in mitsuba::GLTexture.

Bitmap* mitsuba::GPUTexture::getBitmap ( unsigned int  slot = EDefaultPosition)

Retrieve a bitmap from the given slot.

const Bitmap* mitsuba::GPUTexture::getBitmap ( unsigned int  slot = EDefaultPosition) const

Retrieve a bitmap from the given slot.

int mitsuba::GPUTexture::getBitmapCount ( ) const
inline

Return the number of stored bitmaps.

const Color3& mitsuba::GPUTexture::getBorderColor ( ) const
inline

Return the border color.

virtual const Class* mitsuba::GPUTexture::getClass ( ) const
virtual

Retrieve this object's class.

Reimplemented from Object.

Reimplemented in mitsuba::GLTexture.

EComponentFormat mitsuba::GPUTexture::getComponentFormat ( ) const
inline

Return the component format of this texture.

EDepthMode mitsuba::GPUTexture::getDepthMode ( ) const
inline

Return the depth map read mode.

EFilterType mitsuba::GPUTexture::getFilterType ( ) const
inline

Return the filter type.

EFrameBufferType mitsuba::GPUTexture::getFrameBufferType ( ) const
inline

Return the framebuffer type (applies only if type==EFrameBuffer)

Float mitsuba::GPUTexture::getMaxAnisotropy ( ) const
inline

Get the maximal anisotropy.

const std::string& mitsuba::GPUTexture::getName ( ) const
inline

Get the texture name.

virtual Color3 mitsuba::GPUTexture::getPixel ( int  x,
int  y 
) const
pure virtual

Assuming that this is a 2D RGB framebuffer, read a single pixel from the GPU.

Implemented in mitsuba::GLTexture.

EPixelFormat mitsuba::GPUTexture::getPixelFormat ( ) const
inline

Return the pixel format of this texture.

int mitsuba::GPUTexture::getSampleCount ( ) const
inline

Return the number of samples (for multisample color render targets)

Point3i mitsuba::GPUTexture::getSize ( ) const
inline

Return the size in pixels.

const std::set<int>& mitsuba::GPUTexture::getTextureUnits ( ) const
inline

Return the texture units, to which this texture is currently bound.

ETextureType mitsuba::GPUTexture::getType ( ) const
inline

Return the texture type.

EWrapType mitsuba::GPUTexture::getWrapTypeU ( )
inline

Return the wrap type along the U axis.

EWrapType mitsuba::GPUTexture::getWrapTypeV ( )
inline

Return the wrap type along the V axis.

virtual void mitsuba::GPUTexture::init ( )
pure virtual

Upload the texture.

Implemented in mitsuba::GLTexture.

void mitsuba::GPUTexture::initAndRelease ( )

Run init, followed by release.

bool mitsuba::GPUTexture::isMipMapped ( ) const
inline

Return whether mipmapping is enabled.

virtual void mitsuba::GPUTexture::refresh ( )
pure virtual

Refresh (re-upload) the texture.

Implemented in mitsuba::GLTexture.

virtual void mitsuba::GPUTexture::refresh ( const Point2i offset,
const Vector2i size 
)
pure virtual

Refresh (re-upload) a subregion of the texture.

Note: this is only implemented for 2D textures

Implemented in mitsuba::GLTexture.

void mitsuba::GPUTexture::release ( )

Dereference the CPU bitmap associated with the texture.

virtual void mitsuba::GPUTexture::releaseTarget ( )
pure virtual

Deactivate the render target.

Implemented in mitsuba::GLTexture.

void mitsuba::GPUTexture::setBitmap ( unsigned int  slot,
Bitmap bitmap 
)

Store a bitmap in a bitmap slot.

void mitsuba::GPUTexture::setBorderColor ( const Color3 borderColor)
inline

Set the border color (applicable if wrapMode=EClamp/EClampToBorder)

void mitsuba::GPUTexture::setComponentFormat ( EComponentFormat  fmt)
inline

Set the component format of this texture.

void mitsuba::GPUTexture::setDepthMode ( EDepthMode  mode)
inline

Set the depth map read mode.

void mitsuba::GPUTexture::setFilterType ( EFilterType  filterType)
inline

Set the filter type.

void mitsuba::GPUTexture::setFrameBufferType ( EFrameBufferType  frameBufferType)

Set the framebuffer type (applies only if type==EFrameBuffer)

void mitsuba::GPUTexture::setMaxAnisotropy ( Float  maxAnisotropy)
inline

Set the maximal anisotropy.

A value of 1 will result in isotropic texture filtering. A value of 0 (default) will use the global max. anisotropy value

void mitsuba::GPUTexture::setMipMapped ( bool  mipMapped)
inline

Define whether mipmapping is enabled.

void mitsuba::GPUTexture::setName ( const std::string &  name)
inline

Set the texture name.

void mitsuba::GPUTexture::setPixelFormat ( EPixelFormat  fmt)
inline

Set the pixel format of this texture.

void mitsuba::GPUTexture::setSampleCount ( int  samples)
inline

Set the number of samples (for multisample color render targets)

void mitsuba::GPUTexture::setSize ( const Point3i size)
inline

Set the size in pixels.

virtual void mitsuba::GPUTexture::setTargetRegion ( const Point2i offset,
const Vector2i size 
)
pure virtual

Restrict rendering to a sub-region of the texture.

Implemented in mitsuba::GLTexture.

void mitsuba::GPUTexture::setType ( ETextureType  textureType)
inline

Set the texture type.

void mitsuba::GPUTexture::setWrapType ( EWrapType  wrapType)
inline

Set the wrap type.

void mitsuba::GPUTexture::setWrapTypeU ( EWrapType  wrapType)
inline

Set the wrap type along the U axis.

void mitsuba::GPUTexture::setWrapTypeV ( EWrapType  wrapType)
inline

Set the wrap type along the V axis.

std::string mitsuba::GPUTexture::toString ( ) const
virtual

Return a string representation.

Reimplemented from Object.

virtual void mitsuba::GPUTexture::unbind ( ) const
pure virtual

Unbind the texture and disable texturing.

Implemented in mitsuba::GLTexture.

Member Data Documentation

std::vector<Bitmap *> mitsuba::GPUTexture::m_bitmaps
protected
Color3 mitsuba::GPUTexture::m_borderColor
protected
EComponentFormat mitsuba::GPUTexture::m_componentFormat
protected
EDepthMode mitsuba::GPUTexture::m_depthMode
protected
EFrameBufferType mitsuba::GPUTexture::m_fbType
protected
EFilterType mitsuba::GPUTexture::m_filterType
protected
Float mitsuba::GPUTexture::m_maxAnisotropy
protected
bool mitsuba::GPUTexture::m_mipmapped
protected
std::string mitsuba::GPUTexture::m_name
protected
EPixelFormat mitsuba::GPUTexture::m_pixelFormat
protected
int mitsuba::GPUTexture::m_samples
protected
Point3i mitsuba::GPUTexture::m_size
protected
PrimitiveThreadLocal<std::set<int> > mitsuba::GPUTexture::m_textureUnits
mutableprotected
Class* mitsuba::GPUTexture::m_theClass
static
ETextureType mitsuba::GPUTexture::m_type
protected
EWrapType mitsuba::GPUTexture::m_wrapTypeU
protected
EWrapType mitsuba::GPUTexture::m_wrapTypeV
protected

The documentation for this class was generated from the following file: