From 075a2981e11b2f8707860a4066de3e98fa262614 Mon Sep 17 00:00:00 2001 From: chyyran Date: Sun, 8 Sep 2024 11:19:14 -0400 Subject: [PATCH] rt(gl): fix `glShaderSource` going past the buffer --- librashader-runtime-gl/src/util.rs | 7 ++++--- librashader-runtime-gl/tests/triangle.rs | 4 ++-- test/shaders_slang | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/librashader-runtime-gl/src/util.rs b/librashader-runtime-gl/src/util.rs index 204a613..4fcaad3 100644 --- a/librashader-runtime-gl/src/util.rs +++ b/librashader-runtime-gl/src/util.rs @@ -1,4 +1,4 @@ -use gl::types::{GLenum, GLuint}; +use gl::types::{GLenum, GLint, GLuint}; use crate::error; use crate::error::FilterChainError; @@ -6,12 +6,13 @@ use librashader_reflect::back::glsl::GlslVersion; pub unsafe fn gl_compile_shader(stage: GLenum, source: &str) -> error::Result { let (shader, compile_status) = unsafe { + let lens = [source.len() as GLint]; let shader = gl::CreateShader(stage); gl::ShaderSource( shader, 1, - &source.as_bytes().as_ptr().cast(), - std::ptr::null(), + &source.as_ptr().cast(), + lens.as_ptr(), ); gl::CompileShader(shader); let mut compile_status = 0; diff --git a/librashader-runtime-gl/tests/triangle.rs b/librashader-runtime-gl/tests/triangle.rs index 9328d63..78c0707 100644 --- a/librashader-runtime-gl/tests/triangle.rs +++ b/librashader-runtime-gl/tests/triangle.rs @@ -30,8 +30,8 @@ fn triangle_gl46() { let mut filter = FilterChainGL::load_from_path( // "../test/slang-shaders/vhs/VHSPro.slangp", // "../test/slang-shaders/test/history.slangp", - "../test/shaders_slang/crt/crt-royale.slangp", - // "../test/shadersslang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp", + // "../test/shaders_slang/crt/crt-royale.slangp", + "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp", Some(&FilterChainOptionsGL { glsl_version: 0, use_dsa: true, diff --git a/test/shaders_slang b/test/shaders_slang index e04aa57..24f9468 160000 --- a/test/shaders_slang +++ b/test/shaders_slang @@ -1 +1 @@ -Subproject commit e04aa575febae5927db6b445a3c47b8f4221df78 +Subproject commit 24f9468e2ef254fa91464939bc73aa63ce4aedf4