Add the following functions to support texture resource views:
class RenderSystem {
// Creates a resource view for the source texture
// using the same <Texture> interface for seamless interoperability.
Texture* CreateTextureView(Texture& sourceTexture, const TextureViewDescriptor& desc);
/* ... */
};
class Texture {
// Returns true if this texture is a resource view and not the original texture
bool IsResourceView() const;
/* ... */
};
This will also replace the secondary version of the GenerateMips function (which currently generates resource views on demand).
For OpenGL, this is only supported if the GL_ARB_texture_view extension is available on the host platform.
For D3D11, D3D12, and Vulkan there is a respective resource view interface (e.g. VkImageView or ID3D11ShaderResourceView).
For Metal, the same interface MTLTexture is used for both textures and texture-views.
Only the debug layer will keep track of all resource views that refer to a source texture. When a source texture is released, and any of its resource views is still used, the debug layer will throw an error message.
EDIT:
Instead of making texture views part of the Texture interface, they are probably better suited for the ResourceHeap interface. Also simplifies the way of creating multiple different views of the same texture object.
Add the following functions to support texture resource views:
This will also replace the secondary version of the
GenerateMips
function (which currently generates resource views on demand).For OpenGL, this is only supported if the
GL_ARB_texture_view
extension is available on the host platform. For D3D11, D3D12, and Vulkan there is a respective resource view interface (e.g.VkImageView
orID3D11ShaderResourceView
). For Metal, the same interfaceMTLTexture
is used for both textures and texture-views.Only the debug layer will keep track of all resource views that refer to a source texture. When a source texture is released, and any of its resource views is still used, the debug layer will throw an error message.
EDIT: Instead of making texture views part of the
Texture
interface, they are probably better suited for theResourceHeap
interface. Also simplifies the way of creating multiple different views of the same texture object.