Cogs.Core
TexturesD3D12.h
1#pragma once
2
3#include "../Base/TexturesCommon.h"
4
5#include "CommonD3D12.h"
6
7namespace Cogs
8{
9 struct TextureD3D12 : public ResourceD3D12
10 {
12
13 uint32_t width;
14 uint32_t height;
15 uint32_t numSamples;
16
17 TextureFormat format;
18
19 bool needsUpload = false;
20 uint32_t numSubResources = 0;
22 D3D12_RESOURCE_DIMENSION dimension;
23 };
24
26 {
27 TextureHandle texture;
28
29 D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
30 };
31
33 {
34 D3D12_SAMPLER_DESC samplerDesc;
35 };
36
38 {
39 void setDevice(const ResourcePointer<ID3D12Device> & device)
40 {
41 this->device = device;
42 }
43
44 using TexturesCommon::loadTexture;
45 TextureHandle loadTexture(const TextureDescription & desc, const TextureData * data) override;
46 void releaseTexture(TextureHandle textureHandle) override;
47
49 void releaseTextureView(const TextureViewHandle & handle) override;
50
51 void * getNativeHandle(TextureHandle textureHandle) override;
52
53 SamplerStateHandle loadSamplerState(const SamplerState & state) override;
54 void releaseSamplerState(SamplerStateHandle handle) override;
55
56 void generateMipmaps(TextureHandle texureHandle) override;
57
58 void releaseResources() override;
59
63
64 private:
66
67 bool createShaderResourceView(D3D12_SHADER_RESOURCE_VIEW_DESC & desc,
68 TextureD3D12 & texture,
69 const TextureViewDescription & viewDesc,
71 };
72}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Encapsulates state for texture sampling in a state object.
Definition: SamplerState.h:12
ETextureFlags
Texture flags enumeration.
Definition: Flags.h:114
Describes how to fetch data from a texture in shaders.
Definition: ITextures.h:13
void * getNativeHandle(TextureHandle textureHandle) override
Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given...
void releaseSamplerState(SamplerStateHandle handle) override
Release the sampler state with the given handle.
TextureViewHandle createTextureView(TextureViewDescription &viewDescription) override
Create a texture view used to bind a limited view of the texture data to the rendering pipeline.
SamplerStateHandle loadSamplerState(const SamplerState &state) override
Load a sampler state object.
void releaseResources() override
Release all allocated texture resources.
void releaseTexture(TextureHandle textureHandle) override
Release the texture with the given textureHandle.
void releaseTextureView(const TextureViewHandle &handle) override
Release the given texture view.
TextureHandle loadTexture(const TextureDescription &desc, const TextureData *data) override
Load a texture from the given description.
void generateMipmaps(TextureHandle texureHandle) override
Use the graphics device to generate mipmaps for the texture with the given texture handle.