From 19cedc6fd2a26155f4d1816f1f930ae745158ffe Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:36:45 -0300 Subject: gui: one texture2d makes every 2D texture, the atlas, an image's, the scene, the capture and the post chain's ping-pong and bloom ones, in place of six fills of the same create info Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/gui/Post.zig | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'src/gui/Post.zig') diff --git a/src/gui/Post.zig b/src/gui/Post.zig index c0b71d97..64a431b9 100644 --- a/src/gui/Post.zig +++ b/src/gui/Post.zig @@ -383,16 +383,7 @@ pub fn draw(post: *Post, device: *c.SDL_GPUDevice, cmd: *c.SDL_GPUCommandBuffer, if (live > 1 and (post.ping[0] == null or post.ping_w != w or post.ping_h != h)) { for (&post.ping) |*texture| { if (texture.*) |old| c.SDL_ReleaseGPUTexture(device, old); - var info = std.mem.zeroes(c.SDL_GPUTextureCreateInfo); - info.type = c.SDL_GPU_TEXTURETYPE_2D; - info.format = format; - info.usage = c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | c.SDL_GPU_TEXTUREUSAGE_SAMPLER; - info.width = w; - info.height = h; - info.layer_count_or_depth = 1; - info.num_levels = 1; - info.sample_count = c.SDL_GPU_SAMPLECOUNT_1; - texture.* = c.SDL_CreateGPUTexture(device, &info) orelse return error.GpuCreate; + texture.* = gui.texture2d(device, format, c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | c.SDL_GPU_TEXTUREUSAGE_SAMPLER, w, h) orelse return error.GpuCreate; } post.ping_w = w; post.ping_h = h; @@ -482,16 +473,7 @@ fn bloomChain(post: *Post, device: *c.SDL_GPUDevice, cmd: *c.SDL_GPUCommandBuffe if (post.bloom_tex[0] == null or post.bloom_w != w or post.bloom_h != h) { for (&post.bloom_tex, 0..) |*texture, i| { if (texture.*) |old| c.SDL_ReleaseGPUTexture(device, old); - var info = std.mem.zeroes(c.SDL_GPUTextureCreateInfo); - info.type = c.SDL_GPU_TEXTURETYPE_2D; - info.format = bloom_format; - info.usage = c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | c.SDL_GPU_TEXTUREUSAGE_SAMPLER; - info.width = @max(1, w >> @intCast(i + 1)); - info.height = @max(1, h >> @intCast(i + 1)); - info.layer_count_or_depth = 1; - info.num_levels = 1; - info.sample_count = c.SDL_GPU_SAMPLECOUNT_1; - texture.* = c.SDL_CreateGPUTexture(device, &info) orelse return error.GpuCreate; + texture.* = gui.texture2d(device, bloom_format, c.SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | c.SDL_GPU_TEXTUREUSAGE_SAMPLER, @max(1, w >> @intCast(i + 1)), @max(1, h >> @intCast(i + 1))) orelse return error.GpuCreate; } post.bloom_w = w; post.bloom_h = h; -- cgit v1.3