MSamplerState Class Reference

#include <MStateManager.h>

Class Description

Container class for an acquired complete GPU sampler state.

MSamplerState wraps an acquired composite GPU sampler state. This sampler state can be used to set the current GPU sampler state using MStateManager::setSamplerState(myShader, 0, mySamplerState).

Instances of MSamplerState cannot be created or modified by users. You can read the descriptor for an MSamplerState using MSamplerState::desc(), but you cannot set or alter the descriptor directly.

MSamplerState can only be obtained via MStateManager::acquireSamplerState(). To use MStateManager::acquireSamplerState(), create and fill an MSamplerStateDesc instance with the requested state and pass it to MStateManager::acquireSamplerState() which will return the cached unique sampler state of that description. If the unique sampler state did not previously exist in the cache, it is created.

The information included in the sampler state includes texture filter selection, texture address mode selection, mip LOD controls, anisotropy control, and the border color.

Any single given sampler state can be bound to as many GPU sampler stages as needed.

The advantages of using this class rather than setting sampler states explicitly are:

1. Since the states are cached internally, state setting is much faster than setting individual states. 2. Since state is set through the Maya viewport API, Maya can maintain accurate knowledge of the current GPU state, even in the presence of arbitrary plug-ins. This also speeds state setup by reducing redundant state setting and OGL queries. 3. The information is device aware, meaning that it will return the correct results based on the current active device. For example it will return the appropriate values for DirectX versus an OpenGL device.

+ Examples:

Public Types

enum  TextureFilter {
  kMinMagMipPoint = 0, kMinMagPoint_MipLinear = 1, kMinPoint_MagLinear_MipPoint = 0x4, kMinPoint_MagMipLinear = 0x5,
  kMinLinear_MagMipPoint = 0x10, kMinLinear_MagPoint_MipLinear = 0x11, kMinMagLinear_MipPoint = 0x14, kMinMagMipLinear = 0x15,
  kAnisotropic = 0x55
}
 Indicates how to filter a texture sample. More...
 
enum  TextureAddress { kTexWrap = 1, kTexMirror = 2, kTexClamp = 3, kTexBorder = 4 }
 Indicates how to handle texture addresses beyond the canonical (0..1, 0..1) range. More...
 

Public Member Functions

const MSamplerStateDescdesc (MStatus *ReturnStatus=NULL) const
 Get the sampler state descriptor that was used to create the state object. More...
 
void * resourceHandle () const
 This method allows access to the draw API dependent handle for a sampler state. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Member Enumeration Documentation

Indicates how to filter a texture sample.

Enumerator
kMinMagMipPoint 

Use point sampling for minification, magnification, and mip-level sampling.

kMinMagPoint_MipLinear 

Use point sampling for minification and magnification; use linear interpolation for mip-level sampling.

kMinPoint_MagLinear_MipPoint 

Use point sampling for minification; use linear interpolation for magnification; use point sampling for mip-level sampling.

kMinPoint_MagMipLinear 

Use point sampling for minification; use linear interpolation for magnification and mip-level sampling.

kMinLinear_MagMipPoint 

Use linear interpolation for minification; use point sampling for magnification and mip-level sampling.

kMinLinear_MagPoint_MipLinear 

Use linear interpolation for minification; use point sampling for magnification; use linear interpolation for mip-level sampling.

kMinMagLinear_MipPoint 

Use linear interpolation for minification and magnification; use point sampling for mip-level sampling.

kMinMagMipLinear 

Use linear interpolation for minification, magnification, and mip-level sampling.

kAnisotropic 

Use anisotropic filtering for minification, magnification, and mip-level sampling.

Indicates how to handle texture addresses beyond the canonical (0..1, 0..1) range.

Enumerator
kTexWrap 

Wrap addresses beyond the [0,1] tile back into the [0.1] range, repeating the texture over the surface.

kTexMirror 

Similar to wrap, but with odd tiles mirrored in u and v.

kTexClamp 

Clamp address in the [0, 1] range.

Extends edge pixels beyond range.

kTexBorder 

Clamp samples out of [0, 1] range to border color.

Member Function Documentation

const MSamplerStateDesc & desc ( MStatus ReturnStatus = NULL) const

Get the sampler state descriptor that was used to create the state object.

Parameters
[out]ReturnStatusreturn status
Returns
A reference to the sampler state descriptor
Status Codes:
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.
void * resourceHandle ( ) const

This method allows access to the draw API dependent handle for a sampler state.

This handle is owned by the MSamplerState and is provided to allow access to use as a read-only object.

Modifications should never be performed on this handle.

Any modifications may result in unpredictable stability as the MSamplerState no longer has knowledge of it's contents.

For OpenGL, such a handle does not exist and a NULL pointer will be returned.

For DirectX 10 and higher, a pointer to a Direct3D state will be returned.

Returns
A pointer (handle) to the state if successful, otherwise NULL.
+ Examples:

The documentation for this class was generated from the following files:
  • MStateManager.h
  • MStateManager.cpp