summaryrefslogtreecommitdiff
path: root/src/gpu/texture_manager.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-01 16:18:19 +0100
committerskal <pascal.massimino@gmail.com>2026-02-01 16:18:19 +0100
commit1522b95c838fc3e567066fd96dede3dca25cbc95 (patch)
tree24dd8d2bc586f8b9f8f3518b4fe68907e8eeb1d4 /src/gpu/texture_manager.cc
parent1481b0a6313b725eec3e3ebeea085e98703df00f (diff)
feat(gpu): Integrate bumpy 3D renderer into main demo
- Added depth buffer support to MainSequence. - Implemented Hybrid3DEffect for the main timeline. - Fixed effect initialization order in MainSequence. - Ensured depth-stencil compatibility for all scene effects. - Updated demo sequence with 3D elements and post-processing.
Diffstat (limited to 'src/gpu/texture_manager.cc')
-rw-r--r--src/gpu/texture_manager.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/gpu/texture_manager.cc b/src/gpu/texture_manager.cc
index 4240245..f2d93ad 100644
--- a/src/gpu/texture_manager.cc
+++ b/src/gpu/texture_manager.cc
@@ -36,11 +36,21 @@ void TextureManager::create_procedural_texture(
def.gen_func(pixel_data.data(), def.width, def.height, def.params.data(),
(int)def.params.size());
- WGPUExtent3D tex_size = {(uint32_t)def.width, (uint32_t)def.height, 1};
+ create_texture(name, def.width, def.height, pixel_data.data());
+
+#if !defined(STRIP_ALL)
+ std::cout << "Generated procedural texture: " << name << " (" << def.width
+ << "x" << def.height << ")" << std::endl;
+#endif
+}
+
+void TextureManager::create_texture(const std::string& name, int width, int height, const uint8_t* data) {
+ WGPUExtent3D tex_size = {(uint32_t)width, (uint32_t)height, 1};
// 2. Create GPU Texture
WGPUTextureDescriptor tex_desc = {};
- tex_desc.usage = WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopyDst;
+ tex_desc.usage =
+ WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopyDst;
tex_desc.dimension = WGPUTextureDimension_2D;
tex_desc.size = tex_size;
tex_desc.format = WGPUTextureFormat_RGBA8Unorm;
@@ -63,11 +73,11 @@ void TextureManager::create_procedural_texture(
WGPU_TEX_DATA_LAYOUT source_layout = {};
source_layout.offset = 0;
- source_layout.bytesPerRow = def.width * 4;
- source_layout.rowsPerImage = def.height;
+ source_layout.bytesPerRow = width * 4;
+ source_layout.rowsPerImage = height;
- wgpuQueueWriteTexture(queue_, &destination, pixel_data.data(),
- pixel_data.size(), &source_layout, &tex_size);
+ wgpuQueueWriteTexture(queue_, &destination, data,
+ width * height * 4, &source_layout, &tex_size);
// 4. Create View
WGPUTextureViewDescriptor view_desc = {};
@@ -85,15 +95,10 @@ void TextureManager::create_procedural_texture(
GpuTexture gpu_tex;
gpu_tex.texture = texture;
gpu_tex.view = view;
- gpu_tex.width = def.width;
- gpu_tex.height = def.height;
-
+ gpu_tex.width = width;
+ gpu_tex.height = height;
+
textures_[name] = gpu_tex;
-
-#if !defined(STRIP_ALL)
- std::cout << "Generated procedural texture: " << name << " (" << def.width
- << "x" << def.height << ")" << std::endl;
-#endif
}
WGPUTextureView TextureManager::get_texture_view(const std::string& name) {