Cogs.Core
TexturesVK.h
1#pragma once
2
3#include "../Base/TexturesCommon.h"
4
5#include "CommonVK.h"
6
7namespace Cogs
8{
9 struct SamplerVK
10 {
11 VkSampler sampler;
12 };
13
14 struct TextureVK
15 {
16 TextureFormat format;
17 VkFormat vkFormat;
18 uint32_t samples;
19 uint32_t width;
20 uint32_t height;
21 uint32_t mipLevels;
22
23 bool external = false;
24 bool isDepth = false;
25
26 VkImage image;
27 VkDeviceMemory deviceMemory;
28 VkImageView imageView;
29
30 VkDescriptorImageInfo imageInfo;
31
32 VkImageLayout layout;
33 };
34
36 {
37 enum EFlags
38 {
39 Staging = TextureFlags::ExternalTexture << 1,
40 };
41 };
42
43 struct TexturesVK : public TexturesCommon
44 {
45 void initialize(class GraphicsDeviceVK * grapihcsDevice);
46
47 using TexturesCommon::loadTexture;
48 TextureHandle loadTexture(const TextureDescription & desc, const TextureData * data) override;
49 void releaseTexture(TextureHandle textureHandle) override;
50
51 SamplerStateHandle loadSamplerState(const SamplerState & state) override;
52 void releaseSamplerState(SamplerStateHandle handle) override;
53
55 void releaseTextureView(const TextureViewHandle & handle) override;
56 void * getNativeHandle(TextureHandle textureHandle) override;
57
58 void generateMipmaps(TextureHandle textureHandle) override;
59 void releaseResources() override;
60
61 void updateTextureData(const TextureData * data, const uint32_t arraySize, const uint32_t numLevels, TextureVK & texture);
62
65
66 GraphicsDeviceVK * graphicsDevice;
67 VkDevice device;
68 };
69}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Encapsulates state for texture sampling in a state object.
Definition: SamplerState.h:12
Describes how to fetch data from a texture in shaders.
Definition: ITextures.h:13
TextureHandle loadTexture(const TextureDescription &desc, const TextureData *data) override
Load a texture from the given description.
Definition: TexturesVK.cpp:113
void releaseSamplerState(SamplerStateHandle handle) override
Release the sampler state with the given handle.
Definition: TexturesVK.cpp:101
void releaseTextureView(const TextureViewHandle &handle) override
Release the given texture view.
Definition: TexturesVK.cpp:350
SamplerStateHandle loadSamplerState(const SamplerState &state) override
Load a sampler state object.
Definition: TexturesVK.cpp:29
void releaseTexture(TextureHandle textureHandle) override
Release the texture with the given textureHandle.
Definition: TexturesVK.cpp:18
void releaseResources() override
Release all allocated texture resources.
Definition: TexturesVK.cpp:109
TextureViewHandle createTextureView(TextureViewDescription &viewDescription) override
Create a texture view used to bind a limited view of the texture data to the rendering pipeline.
Definition: TexturesVK.cpp:345
void generateMipmaps(TextureHandle textureHandle) override
Use the graphics device to generate mipmaps for the texture with the given texture handle.
Definition: TexturesVK.cpp:105
void * getNativeHandle(TextureHandle textureHandle) override
Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given...
Definition: TexturesVK.cpp:354