gl: use real texture names when fixing bindings
This commit is contained in:
parent
daea19b5a2
commit
6d11323520
|
@ -7,7 +7,7 @@ use crate::reflect::ReflectShader;
|
||||||
|
|
||||||
pub type GlVersion = spirv_cross::glsl::Version;
|
pub type GlVersion = spirv_cross::glsl::Version;
|
||||||
pub struct GlslangGlslContext {
|
pub struct GlslangGlslContext {
|
||||||
pub sampler_bindings: Vec<u32>,
|
pub sampler_bindings: Vec<(String, u32)>,
|
||||||
pub compiler: CompiledAst<spirv_cross::glsl::Target>,
|
pub compiler: CompiledAst<spirv_cross::glsl::Target>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -792,15 +792,15 @@ impl CompileShader<GLSL> for CrossReflect<glsl::Target> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut texture_fixups = Vec::new();
|
let mut texture_fixups = Vec::new();
|
||||||
for res in &fragment_resources.sampled_images {
|
for res in fragment_resources.sampled_images {
|
||||||
let binding = self.fragment.get_decoration(res.id, Decoration::Binding)?;
|
let binding = self.fragment.get_decoration(res.id, Decoration::Binding)?;
|
||||||
self.fragment
|
|
||||||
.set_name(res.id, &format!("LIBRA_TEXTURE_{binding}"))?;
|
|
||||||
self.fragment
|
self.fragment
|
||||||
.unset_decoration(res.id, Decoration::DescriptorSet)?;
|
.unset_decoration(res.id, Decoration::DescriptorSet)?;
|
||||||
self.fragment
|
self.fragment
|
||||||
.unset_decoration(res.id, Decoration::Binding)?;
|
.unset_decoration(res.id, Decoration::Binding)?;
|
||||||
texture_fixups.push(binding);
|
let mut name = res.name;
|
||||||
|
name.push('\0');
|
||||||
|
texture_fixups.push((name, binding));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ShaderCompilerOutput {
|
Ok(ShaderCompilerOutput {
|
||||||
|
|
|
@ -402,10 +402,9 @@ impl FilterChain {
|
||||||
|
|
||||||
gl::UseProgram(program);
|
gl::UseProgram(program);
|
||||||
|
|
||||||
for binding in &glsl.context.sampler_bindings {
|
for (name, binding) in &glsl.context.sampler_bindings {
|
||||||
let loc_name = format!("LIBRA_TEXTURE_{}\0", *binding);
|
|
||||||
let location =
|
let location =
|
||||||
gl::GetUniformLocation(program, loc_name.as_str().as_ptr().cast());
|
gl::GetUniformLocation(program, name.as_str().as_ptr().cast());
|
||||||
if location >= 0 {
|
if location >= 0 {
|
||||||
// eprintln!("setting sampler {location} to sample from {binding}");
|
// eprintln!("setting sampler {location} to sample from {binding}");
|
||||||
gl::Uniform1i(location, *binding as GLint);
|
gl::Uniform1i(location, *binding as GLint);
|
||||||
|
|
Loading…
Reference in a new issue