summaryrefslogtreecommitdiff
path: root/src/renderer/OpenGL.zig
diff options
context:
space:
mode:
authorMitchell Hashimoto <m@mitchellh.com>2025-09-18 08:57:47 -0700
committerMitchell Hashimoto <m@mitchellh.com>2025-09-18 09:25:37 -0700
commita45368161507343c5ce540c2e2bb9ba41bc46e91 (patch)
treea1674216eaf90e90a436cff8875e58273fe1af8e /src/renderer/OpenGL.zig
parenta3643f8f5205b1e1d0a85b103202977a5a251e68 (diff)
renderer: create explicit sampler state for custom shaders
The GLSL to MSL conversion process uses a passed-in sampler state for the `iChannel0` parameter and we weren't providing it. This magically worked on Apple Silicon for unknown reasons but failed on Intel GPUs. In normal, hand-written MSL, we'd explicitly create the sampler state as a normal variable (we do this in `shaders.metal` already!), but the Shadertoy conversion stuff doesn't do this, probably because the exact sampler parameters can't be safely known. This fixes a Metal validation error when using custom shaders: ``` -[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:5970: failed assertion `Draw Errors Validation Fragment Function(main0): missing Sampler binding at index 0 for iChannel0Smplr[0]. ```
Diffstat (limited to 'src/renderer/OpenGL.zig')
-rw-r--r--src/renderer/OpenGL.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig
index e572806d1..673f79501 100644
--- a/src/renderer/OpenGL.zig
+++ b/src/renderer/OpenGL.zig
@@ -20,6 +20,7 @@ pub const RenderPass = @import("opengl/RenderPass.zig");
pub const Pipeline = @import("opengl/Pipeline.zig");
const bufferpkg = @import("opengl/buffer.zig");
pub const Buffer = bufferpkg.Buffer;
+pub const Sampler = @import("opengl/Sampler.zig");
pub const Texture = @import("opengl/Texture.zig");
pub const shaders = @import("opengl/shaders.zig");
@@ -364,6 +365,17 @@ pub inline fn textureOptions(self: OpenGL) Texture.Options {
};
}
+/// Returns the options to use when constructing samplers.
+pub inline fn samplerOptions(self: OpenGL) Sampler.Options {
+ _ = self;
+ return .{
+ .min_filter = .linear,
+ .mag_filter = .linear,
+ .wrap_s = .clamp_to_edge,
+ .wrap_t = .clamp_to_edge,
+ };
+}
+
/// Pixel format for image texture options.
pub const ImageTextureFormat = enum {
/// 1 byte per pixel grayscale.