Cogs.Core
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Cogs::TexturesD3D11 Struct Reference
Inheritance diagram for Cogs::TexturesD3D11:
Cogs::TexturesCommon Cogs::ITextures

Public Member Functions

 TexturesD3D11 (struct GraphicsDeviceD3D11 *device)
 
void initialize (struct ContextD3D11 *context_set)
 
void annotate (TextureHandle handle, const StringView &name) override
 Associate a name with an object for use in graphics debugging.
 
TextureHandle loadTexture (const TextureDescription &desc, const TextureData *data) override
 Load a texture from the given description.
 
void releaseTexture (TextureHandle textureHandle) override
 Release the texture with the given textureHandle.
 
TextureViewHandle createTextureView (TextureViewDescription &view) override
 Create a texture view used to bind a limited view of the texture data to the rendering pipeline.
 
void releaseTextureView (const TextureViewHandle &handle) override
 Release the given texture view.
 
SamplerStateHandle loadSamplerState (const SamplerState &state) override
 Load a sampler state object.
 
void releaseSamplerState (SamplerStateHandle handle) override
 Release the sampler state with the given handle.
 
void generateMipmaps (TextureHandle texureHandle) override
 Use the graphics device to generate mipmaps for the texture with the given texture handle.
 
void * getNativeHandle (TextureHandle textureHandle) override
 Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given texture handle.
 
void releaseResources () override
 Release all allocated texture resources.
 
ID3D11Resource * getTexture (TextureHandle textureHandle)
 
ID3D11Texture2D * getTexture2D (TextureHandle textureHandle)
 
TextureHandle loadTexture (const uint8_t *bytes, uint32_t width, uint32_t height, TextureFormat format, uint32_t flags) final
 
TextureHandle loadTexture (const uint8_t *bytes, uint32_t width, uint32_t height, TextureFormat format, uint32_t numSamples, uint32_t flags) final
 
TextureHandle loadTexture (const TextureDescription &desc, const TextureData *data)=0
 Load a texture from the given description.
 
virtual TextureHandle loadTexture (const unsigned char *bytes, unsigned int width, unsigned int height, TextureFormat format, unsigned int flags=0)=0
 Load a texture using the given data to populate the texture contents.
 
virtual TextureHandle loadTexture (const unsigned char *bytes, unsigned int width, unsigned int height, TextureFormat format, unsigned int numSamples, unsigned int flags)=0
 Load a texture using the given data to populate the texture contents.
 
virtual TextureHandle loadTexture (const TextureDescription &desc, const TextureData *data)=0
 Load a texture from the given description.
 
- Public Member Functions inherited from Cogs::TexturesCommon
TextureHandle loadTexture (const uint8_t *bytes, uint32_t width, uint32_t height, TextureFormat format, uint32_t flags) final
 
TextureHandle loadTexture (const uint8_t *bytes, uint32_t width, uint32_t height, TextureFormat format, uint32_t numSamples, uint32_t flags) final
 
TextureHandle loadTextureMipMaps (const uint8_t **bytes, size_t numLevels, const uint32_t *widths, const uint32_t *heights, TextureFormat format, uint32_t flags=0) final
 
TextureHandle loadTextureArray (const uint8_t **bytes, const size_t arraySize, const size_t numLevels, const uint32_t *widths, const uint32_t *heights, TextureFormat format, uint32_t flags=0) final
 
TextureHandle loadCubeMap (const uint8_t **bytes, const size_t arraySize, const size_t numLevels, const uint32_t *widths, const uint32_t *heights, TextureFormat format, uint32_t flags=0) final
 
TextureHandle load (ResourceDimensions target, const uint8_t **bytes, const size_t arraySize, const size_t numLevels, const uint32_t *widths, const uint32_t *heights, TextureFormat format, uint32_t numSamples, uint32_t flags)
 
TextureHandle loadTexture (const TextureDescription &desc, const TextureData *data)=0
 Load a texture from the given description.
 
virtual TextureHandle loadTexture (const unsigned char *bytes, unsigned int width, unsigned int height, TextureFormat format, unsigned int flags=0)=0
 Load a texture using the given data to populate the texture contents.
 
virtual TextureHandle loadTexture (const unsigned char *bytes, unsigned int width, unsigned int height, TextureFormat format, unsigned int numSamples, unsigned int flags)=0
 Load a texture using the given data to populate the texture contents.
 
virtual TextureHandle loadTexture (const TextureDescription &desc, const TextureData *data)=0
 Load a texture from the given description.
 
- Public Member Functions inherited from Cogs::ITextures
virtual void annotate (TextureHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual TextureHandle loadTexture (const unsigned char *bytes, unsigned int width, unsigned int height, TextureFormat format, unsigned int flags=0)=0
 Load a texture using the given data to populate the texture contents.
 
virtual TextureHandle loadTexture (const unsigned char *bytes, unsigned int width, unsigned int height, TextureFormat format, unsigned int numSamples, unsigned int flags)=0
 Load a texture using the given data to populate the texture contents.
 
virtual TextureHandle loadTextureMipMaps (const unsigned char **bytes, size_t numLevels, const unsigned int *widths, const unsigned int *heights, TextureFormat format, unsigned int flags=0)=0
 Load a texture with multiple mipmap levels using the given data to populate the texture contents.
 
virtual TextureHandle loadTextureArray (const unsigned char **bytes, const size_t arraySize, const size_t numLevels, const unsigned int *widths, const unsigned int *heights, TextureFormat format, unsigned int flags=0)=0
 Load an array texture with mipmaps using the given data to populate the texture contents.
 
virtual TextureHandle loadCubeMap (const unsigned char **bytes, const size_t arraySize, const size_t numLevels, const unsigned int *widths, const unsigned int *heights, TextureFormat format, unsigned int flags=0)=0
 Load a cube map texture with mipmaps using the given data to populate the texture contents.
 
virtual TextureHandle loadTexture (const TextureDescription &desc, const TextureData *data)=0
 Load a texture from the given description.
 
virtual void uploadTextureData (TextureHandle textureHandle, const TextureData &data, uint32_t layer_offset=0, uint32_t face_offset=0, uint32_t level_offset=0)
 Upload a texture from the given description.
 
virtual void releaseTexture (TextureHandle textureHandle)=0
 Release the texture with the given textureHandle.
 
virtual void releaseNativeTexture (TextureNativeHandle nativeHandle)
 Release a native texture handle.
 
virtual TextureViewHandle createTextureView (TextureViewDescription &viewDescription)=0
 Create a texture view used to bind a limited view of the texture data to the rendering pipeline.
 
virtual void releaseTextureView (const TextureViewHandle &handle)=0
 Release the given texture view.
 
virtual SamplerStateHandle loadSamplerState (const SamplerState &state)=0
 Load a sampler state object.
 
virtual void releaseSamplerState (SamplerStateHandle handle)=0
 Release the sampler state with the given handle.
 
virtual void generateMipmaps (TextureHandle textureHandle)=0
 Use the graphics device to generate mipmaps for the texture with the given texture handle.
 
virtual void * getNativeHandle (TextureHandle textureHandle)=0
 Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given texture handle.
 
virtual void releaseResources ()=0
 Release all allocated texture resources.
 

Public Attributes

size_t textureMemoryConsumption = 0
 
SafeResourceMap< TextureHandle, TextureD3D11textures
 
SafeResourceMap< TextureViewHandle, TextureViewD3D11textureViews
 
ResourceMap< SamplerStateHandle, SamplerStateD3D11samplerStates
 

Private Member Functions

ResourcePointer< ID3D11ShaderResourceView > createShaderResourceView (ID3D11Resource *resource, uint32_t flags=0, uint32_t mostDetailedMip=0, uint32_t mipLevels=~0)
 

Private Attributes

struct GraphicsDeviceD3D11graphicsDevice = nullptr
 
ContextD3D11context = nullptr
 
ResourcePointer< ID3D11Device > device
 

Detailed Description

Definition at line 36 of file TexturesD3D11.h.

Constructor & Destructor Documentation

◆ TexturesD3D11()

Cogs::TexturesD3D11::TexturesD3D11 ( struct GraphicsDeviceD3D11 device)

Definition at line 17 of file TexturesD3D11.cpp.

Member Function Documentation

◆ annotate()

void Cogs::TexturesD3D11::annotate ( TextureHandle  handle,
const StringView name 
)
overridevirtual

Associate a name with an object for use in graphics debugging.

Reimplemented from Cogs::ITextures.

Definition at line 24 of file TexturesD3D11.cpp.

References Cogs::StringView::data(), Cogs::StringView::empty(), and Cogs::StringView::length().

◆ createShaderResourceView()

Cogs::ResourcePointer< ID3D11ShaderResourceView > Cogs::TexturesD3D11::createShaderResourceView ( ID3D11Resource *  resource,
uint32_t  flags = 0,
uint32_t  mostDetailedMip = 0,
uint32_t  mipLevels = ~0 
)
private

Definition at line 348 of file TexturesD3D11.cpp.

◆ createTextureView()

Cogs::TextureViewHandle Cogs::TexturesD3D11::createTextureView ( TextureViewDescription viewDescription)
overridevirtual

Create a texture view used to bind a limited view of the texture data to the rendering pipeline.

Parameters
viewDescriptionDescription of the texture view.
Returns
Handle to the create texture view, InvalidHandle if error.

Implements Cogs::ITextures.

Definition at line 328 of file TexturesD3D11.cpp.

References Cogs::Handle_t< TextureViewTag >::InvalidHandle, Cogs::TextureViewDescription::levelIndex, Cogs::TextureViewDescription::numLevels, and Cogs::TextureViewDescription::texture.

◆ generateMipmaps()

void Cogs::TexturesD3D11::generateMipmaps ( TextureHandle  textureHandle)
overridevirtual

Use the graphics device to generate mipmaps for the texture with the given texture handle.

Parameters
textureHandleValid handle to a previously created texture object. The texture must have been created with the TextureFlags::GenerateMipMaps flag.

Implements Cogs::ITextures.

Definition at line 501 of file TexturesD3D11.cpp.

◆ getNativeHandle()

void * Cogs::TexturesD3D11::getNativeHandle ( TextureHandle  textureHandle)
overridevirtual

Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given texture handle.

Parameters
textureHandleValid handle to a previously created texture object.
Returns
Native handle

Implements Cogs::ITextures.

Definition at line 495 of file TexturesD3D11.cpp.

◆ getTexture()

ID3D11Resource * Cogs::TexturesD3D11::getTexture ( TextureHandle  textureHandle)
inline

Definition at line 63 of file TexturesD3D11.h.

◆ getTexture2D()

ID3D11Texture2D * Cogs::TexturesD3D11::getTexture2D ( TextureHandle  textureHandle)
inline

Definition at line 67 of file TexturesD3D11.h.

◆ initialize()

void Cogs::TexturesD3D11::initialize ( struct ContextD3D11 context_set)
inline

Definition at line 40 of file TexturesD3D11.h.

◆ loadSamplerState()

Cogs::SamplerStateHandle Cogs::TexturesD3D11::loadSamplerState ( const SamplerState state)
overridevirtual

Load a sampler state object.

Parameters
stateSampler state structure used to initialize the sampler state object on the graphics device.
Returns
Handle to the newly created sampler state object, InvalidHandle if the operation failed.

Implements Cogs::ITextures.

Definition at line 454 of file TexturesD3D11.cpp.

References Cogs::SamplerState::addressModeS, Cogs::SamplerState::addressModeT, Cogs::SamplerState::addressModeW, Cogs::SamplerState::borderColor, Cogs::SamplerState::comparisonFunction, Cogs::SamplerState::filter, Cogs::Handle_t< SamplerTag >::InvalidHandle, and Cogs::SamplerState::maxAnisotropy.

◆ loadTexture() [1/7]

Cogs::TextureHandle Cogs::TexturesD3D11::loadTexture ( const TextureDescription desc,
const TextureData data 
)
overridevirtual

◆ loadTexture() [2/7]

TextureHandle Cogs::TexturesCommon::loadTexture ( const TextureDescription desc,
const TextureData data 
)
virtual

Load a texture from the given description.

Parameters
descTexture description.
dataOptional texture content.

Implements Cogs::TexturesCommon.

◆ loadTexture() [3/7]

virtual TextureHandle Cogs::ITextures::loadTexture ( const TextureDescription desc,
const TextureData data 
)
virtual

Load a texture from the given description.

Parameters
descTexture description.
dataOptional texture content.

Implements Cogs::TexturesCommon.

◆ loadTexture() [4/7]

Cogs::TextureHandle Cogs::TexturesCommon::loadTexture ( const uint8_t *  bytes,
uint32_t  width,
uint32_t  height,
TextureFormat  format,
uint32_t  flags 
)
final

Definition at line 10 of file TexturesCommon.cpp.

◆ loadTexture() [5/7]

Cogs::TextureHandle Cogs::TexturesCommon::loadTexture ( const uint8_t *  bytes,
uint32_t  width,
uint32_t  height,
TextureFormat  format,
uint32_t  numSamples,
uint32_t  flags 
)
final

Definition at line 11 of file TexturesCommon.cpp.

◆ loadTexture() [6/7]

virtual TextureHandle Cogs::ITextures::loadTexture ( const unsigned char *  bytes,
unsigned int  width,
unsigned int  height,
TextureFormat  format,
unsigned int  flags = 0 
)
virtual

Load a texture using the given data to populate the texture contents.

Parameters
bytesPointer to texture data. If nullptr is given an empty texture with the given dimensions and format is created.
widthWidth of the texture in pixels.
heightHeight of the texture in pixels.
formatFormat of the texture data.
flagsTexture flags used to determine which operations are supported by the created texture.
Returns
Handle to the newly created texture object, InvalidHandle if the operation failed.

Reimplemented from Cogs::TexturesCommon.

◆ loadTexture() [7/7]

virtual TextureHandle Cogs::ITextures::loadTexture ( const unsigned char *  bytes,
unsigned int  width,
unsigned int  height,
TextureFormat  format,
unsigned int  numSamples,
unsigned int  flags 
)
virtual

Load a texture using the given data to populate the texture contents.

Parameters
bytesPointer to texture data. If nullptr is given an empty texture with the given dimensions and format is created.
widthWidth of the texture in pixels.
heightHeight of the texture in pixels.
formatFormat of the texture data.
numSamplesNumber of samples to use per pixel in the texture.
flagsTexture flags used to determine which operations are supported by the created texture.
Returns
Handle to the newly created texture object, InvalidHandle if the operation failed.

Reimplemented from Cogs::TexturesCommon.

◆ releaseResources()

void Cogs::TexturesD3D11::releaseResources ( )
overridevirtual

Release all allocated texture resources.

Implements Cogs::ITextures.

Definition at line 509 of file TexturesD3D11.cpp.

◆ releaseSamplerState()

void Cogs::TexturesD3D11::releaseSamplerState ( SamplerStateHandle  handle)
overridevirtual

Release the sampler state with the given handle.

Parameters
handleValid handle to a previously created sampler state.

Implements Cogs::ITextures.

Definition at line 490 of file TexturesD3D11.cpp.

◆ releaseTexture()

void Cogs::TexturesD3D11::releaseTexture ( TextureHandle  textureHandle)
overridevirtual

Release the texture with the given textureHandle.

Parameters
textureHandleValid handle to a previously created texture object.

Implements Cogs::ITextures.

Definition at line 314 of file TexturesD3D11.cpp.

References Cogs::EnableTraceLogging, and Cogs::TextureDescription::estimateMemorySize().

◆ releaseTextureView()

void Cogs::TexturesD3D11::releaseTextureView ( const TextureViewHandle handle)
overridevirtual

Release the given texture view.

Parameters
handleValid handle to a previously created texture view.

Implements Cogs::ITextures.

Definition at line 343 of file TexturesD3D11.cpp.

Member Data Documentation

◆ context

ContextD3D11* Cogs::TexturesD3D11::context = nullptr
private

Definition at line 78 of file TexturesD3D11.h.

◆ device

ResourcePointer<ID3D11Device> Cogs::TexturesD3D11::device
private

Definition at line 79 of file TexturesD3D11.h.

◆ graphicsDevice

struct GraphicsDeviceD3D11* Cogs::TexturesD3D11::graphicsDevice = nullptr
private

Definition at line 77 of file TexturesD3D11.h.

◆ samplerStates

ResourceMap<SamplerStateHandle, SamplerStateD3D11> Cogs::TexturesD3D11::samplerStates

Definition at line 74 of file TexturesD3D11.h.

◆ textureMemoryConsumption

size_t Cogs::TexturesD3D11::textureMemoryConsumption = 0

Definition at line 71 of file TexturesD3D11.h.

◆ textures

SafeResourceMap<TextureHandle, TextureD3D11> Cogs::TexturesD3D11::textures

Definition at line 72 of file TexturesD3D11.h.

◆ textureViews

SafeResourceMap<TextureViewHandle, TextureViewD3D11> Cogs::TexturesD3D11::textureViews

Definition at line 73 of file TexturesD3D11.h.


The documentation for this struct was generated from the following files: