Cogs.Core
TexturesWebGPU.h
1#pragma once
2
3#include "CommonWebGPU.h"
4
5#include "../Base/TexturesCommon.h"
6#include "../Base/ResourceMap.h"
7
8namespace Cogs {
10 WGPUTexture texture;
11
12 WGPUTextureFormat view_format;
13 WGPUTextureViewDimension view_dimension;
14 WGPUTextureView texture_view;
15
16 uint32_t width;
17 uint32_t height;
18 uint32_t samples;
19 };
21 WGPUTextureView texture_view;
22 };
24 WGPUSampler sampler;
25 };
26
28 public:
29 using TexturesCommon::loadTexture;
30
31 void initialize(class GraphicsDeviceWebGPU *graphicsDevice);
32
33 virtual void annotate(TextureHandle handle, const StringView& name) override;
34
35 virtual TextureHandle loadTexture(const TextureDescription& desc, const TextureData* data) override;
36
37 virtual void releaseTexture(TextureHandle textureHandle) override;
38
40 virtual void releaseTextureView(const TextureViewHandle &handle) override;
41
42 virtual SamplerStateHandle loadSamplerState(const SamplerState& state) override;
43 virtual void releaseSamplerState(SamplerStateHandle handle) override;
44
45 virtual void generateMipmaps(TextureHandle handle) override;
46 virtual void releaseResources() override;
47
48 virtual void* getNativeHandle(TextureHandle handle) override
49 {
50 return reinterpret_cast<void*>(textures[handle].texture);
51 }
52
56
57 class GraphicsDeviceWebGPU *graphicsDevice;
58 };
59}
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
virtual void generateMipmaps(TextureHandle handle) override
Use the graphics device to generate mipmaps for the texture with the given texture handle.
virtual void releaseTexture(TextureHandle textureHandle) override
Release the texture with the given textureHandle.
virtual void releaseSamplerState(SamplerStateHandle handle) override
Release the sampler state with the given handle.
virtual SamplerStateHandle loadSamplerState(const SamplerState &state) override
Load a sampler state object.
virtual void annotate(TextureHandle handle, const StringView &name) override
Associate a name with an object for use in graphics debugging.
virtual TextureHandle loadTexture(const TextureDescription &desc, const TextureData *data) override
Load a texture from the given description.
virtual void releaseTextureView(const TextureViewHandle &handle) override
Release the given texture view.
virtual TextureViewHandle createTextureView(TextureViewDescription &view) override
Create a texture view used to bind a limited view of the texture data to the rendering pipeline.
virtual void releaseResources() override
Release all allocated texture resources.
virtual void * getNativeHandle(TextureHandle handle) override
Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given...
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