From c4328c2bba757496f35996a56fa24f689989b717 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Tue, 16 Dec 2025 21:35:29 -0800 Subject: [PATCH] chore: remove logs --- ScreenShader/renderer.swift | 42 +-------------------- ScreenShader/retroarch_shader.swift | 57 +---------------------------- 2 files changed, 4 insertions(+), 95 deletions(-) diff --git a/ScreenShader/renderer.swift b/ScreenShader/renderer.swift index 1b26320..a0c1258 100644 --- a/ScreenShader/renderer.swift +++ b/ScreenShader/renderer.swift @@ -145,10 +145,6 @@ class MetalRenderer { shaderDirectory: shaderDirectory ) - print("=== RetroArch-generated Metal code ===") - print(compiled.metalSource) - print("=== End RetroArch-generated Metal code ===") - let library: MTLLibrary do { library = try device.makeLibrary(source: compiled.metalSource, options: nil) @@ -207,11 +203,6 @@ class MetalRenderer { ]) } - // Debug: print the generated Metal code - print("=== Slang-generated Metal code ===") - print(metalFragmentSource) - print("=== End Slang-generated Metal code ===") - // Slang generates a complete Metal file with its own includes. // We need to add our vertex shader to it, but avoid duplicate includes. // Strip the Slang includes and add our vertex shader after. @@ -319,11 +310,6 @@ class MetalRenderer { // Load background texture if the shader uses one loadBackgroundTextureIfNeeded(effectSource: effectSource) - - print("Loaded RetroArch shader with \(parameters.count) parameters") - for param in parameters { - print(" - \(param.name): \(param.description) [\(param.minValue) - \(param.maxValue), default: \(param.defaultValue)]") - } } catch { self.renderPipeline = nil self.activeShaderType = .none @@ -357,10 +343,6 @@ class MetalRenderer { let shaderSource = try String(contentsOf: shaderURL, encoding: .utf8) self.activeEffectSource = shaderSource - print("Loaded preset from: \(presetPath)") - print(" Shader: \(preset.shaderPath)") - print(" Textures: \(preset.textures.map { $0.name }.joined(separator: ", "))") - // Compile the shader let (pipeline, parameters) = try Self.buildRetroArchPipeline( device: self.device, @@ -389,16 +371,9 @@ class MetalRenderer { let textureURL = preset.resolvePath(texture.path) if texture.name == "BACKGROUND" { loadTexture(from: textureURL, linear: texture.linear) - print(" Loaded BACKGROUND texture: \(texture.path)") } // TODO: Support additional textures (would need to track by name) } - - print("Loaded RetroArch shader with \(parameters.count) parameters") - for param in parameters { - let value = self.parameterState.getValue(for: param.name) - print(" - \(param.name): \(value) [\(param.minValue) - \(param.maxValue)]") - } } /// Load background texture if the shader references BACKGROUND sampler @@ -450,29 +425,16 @@ class MetalRenderer { let textureLoader = MTKTextureLoader(device: device) do { // Load texture and let MTKTextureLoader handle format - // For grayscale textures, we need to expand to RGBA for proper sampling - var texture = try textureLoader.newTexture( + let texture = try textureLoader.newTexture( URL: url, options: [ .textureUsage: MTLTextureUsage.shaderRead.rawValue, .textureStorageMode: MTLStorageMode.private.rawValue ] ) - - print("Loaded background texture: \(url.lastPathComponent) (linear filtering: \(linear))") - print(" Texture size: \(texture.width)x\(texture.height), format: \(texture.pixelFormat.rawValue)") - - // Check if it's a single-channel (grayscale) texture and convert to RGBA - // Metal grayscale textures only populate .r channel when sampled - if texture.pixelFormat == .r8Unorm || texture.pixelFormat == .r8Unorm_srgb { - print(" Grayscale texture detected - will use swizzle in shader or expect .rrr sampling") - // Note: The shader should sample as .rrr to expand grayscale to RGB - // We'll handle this by creating a texture view with proper swizzle if possible - } - self.backgroundTexture = texture } catch { - print("Failed to load background texture: \(error)") + // Silently fail - shader will use fallback } } diff --git a/ScreenShader/retroarch_shader.swift b/ScreenShader/retroarch_shader.swift index 6ee1d2e..d466958 100644 --- a/ScreenShader/retroarch_shader.swift +++ b/ScreenShader/retroarch_shader.swift @@ -342,19 +342,6 @@ class RetroArchShaderCompiler { let vertexSource = vertexSharedLines.joined(separator: "\n") + "\n" + vertexLines.joined(separator: "\n") let fragmentSource = fragmentSharedLines.joined(separator: "\n") + "\n" + fragmentLines.joined(separator: "\n") - print("=== Preprocessed Shader ===") - print("Parameters found: \(parameters.map { $0.name })") - print("Samplers found: \(samplers.map { $0.name })") - print("Vertex lines: \(vertexLines.count), Fragment lines: \(fragmentLines.count), Shared lines: \(sharedLines.count)") - - print("\n=== VERTEX SOURCE ===") - print(vertexSource) - print("=== END VERTEX SOURCE ===\n") - - print("\n=== FRAGMENT SOURCE ===") - print(fragmentSource) - print("=== END FRAGMENT SOURCE ===\n") - return RetroArchShaderStages( vertexSource: vertexSource, fragmentSource: fragmentSource, @@ -401,39 +388,25 @@ class RetroArchShaderCompiler { /// Compile a RetroArch shader source to Metal static func compileToMetal(source: String, shaderDirectory: URL? = nil) throws -> CompiledRetroArchShader { - print("=== RetroArchShaderCompiler.compileToMetal ===") - print("Source length: \(source.count) characters") - print("Shader directory: \(shaderDirectory?.path ?? "nil")") - guard let glslangPath = findGlslang() else { - print("ERROR: glslang not found!") throw RetroArchShaderError.glslangNotFound } - print("glslang found at: \(glslangPath)") guard let spirvCrossPath = findSpirvCross() else { - print("ERROR: spirv-cross not found!") throw RetroArchShaderError.spirvCrossNotFound } - print("spirv-cross found at: \(spirvCrossPath)") // Preprocess the shader - print("Preprocessing shader...") let stages = try preprocess(source) - print("Vertex source length: \(stages.vertexSource.count)") - print("Fragment source length: \(stages.fragmentSource.count)") - // Create temp directory let tempDir = FileManager.default.temporaryDirectory .appendingPathComponent(UUID().uuidString) try FileManager.default.createDirectory(at: tempDir, withIntermediateDirectories: true) - print("Temp directory: \(tempDir.path)") defer { - // Don't remove temp dir for debugging - print("Temp files preserved at: \(tempDir.path)") - // try? FileManager.default.removeItem(at: tempDir) + // Clean up temp files + try? FileManager.default.removeItem(at: tempDir) } // Compile vertex shader: GLSL -> SPIRV -> Metal @@ -488,13 +461,6 @@ class RetroArchShaderCompiler { // Write GLSL source try source.write(to: inputFile, atomically: true, encoding: .utf8) - // Debug: print the source being compiled - print("=== Compiling \(stage) shader ===") - print("Source file: \(inputFile.path)") - print("First 500 chars of source:") - print(String(source.prefix(500))) - print("===") - // Step 1: GLSL -> SPIRV using glslangValidator let glslangProcess = Process() glslangProcess.executableURL = URL(fileURLWithPath: glslangPath) @@ -511,8 +477,6 @@ class RetroArchShaderCompiler { glslangProcess.arguments?.insert("-I\(dir.path)", at: 1) } - print("Running: \(glslangPath) \(glslangProcess.arguments?.joined(separator: " ") ?? "")") - // Use file-based output capture for more reliable error capture let glslangStdoutFile = tempDir.appendingPathComponent("glslang_stdout.txt") let glslangStderrFile = tempDir.appendingPathComponent("glslang_stderr.txt") @@ -539,14 +503,6 @@ class RetroArchShaderCompiler { let stdoutMessage = (try? String(contentsOf: glslangStdoutFile, encoding: .utf8)) ?? "" let stderrMessage = (try? String(contentsOf: glslangStderrFile, encoding: .utf8)) ?? "" - print("glslang exit code: \(glslangProcess.terminationStatus)") - if !stdoutMessage.isEmpty { - print("glslang stdout: \(stdoutMessage)") - } - if !stderrMessage.isEmpty { - print("glslang stderr: \(stderrMessage)") - } - if glslangProcess.terminationStatus != 0 { let combinedError = [stdoutMessage, stderrMessage] .filter { !$0.isEmpty } @@ -727,15 +683,6 @@ class RetroArchShaderCompiler { fragmentFunction = lines.joined(separator: "\n") } - // Debug: print extracted components - print("=== Extracted sharedStructs ===") - print(sharedStructs) - print("=== Extracted fragmentOutStruct ===") - print(fragmentOutStruct) - print("=== Extracted fragmentFunction ===") - print(fragmentFunction) - print("=== End extraction debug ===") - // Build combined shader with custom vertex shader let combined = """ // Combined RetroArch shader compiled for Metal -- 2.51.2