Skip to content

Commit b95779d

Browse files
authored
Merge pull request glium#2073 from justincredible/compute-shader
Prevent debug error on compute shader creation
2 parents 9bf6a00 + d5d2d3d commit b95779d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/program/reflection.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ fn glenum_to_transform_feedback_mode(value: gl::types::GLenum) -> TransformFeedb
11201120
}
11211121

11221122
/// Contains all subroutine data of a program.
1123-
#[derive(Debug, Clone)]
1123+
#[derive(Debug, Default, Clone)]
11241124
pub struct SubroutineData {
11251125
/// Number of subroutine uniform locations per shader stage.
11261126
/// This is *not* equal to the number of subroutine uniforms per stage,
@@ -1215,21 +1215,22 @@ pub unsafe fn reflect_subroutine_data(ctxt: &mut CommandContext<'_>, program: Ha
12151215
-> SubroutineData
12161216
{
12171217
if !program::is_subroutine_supported(ctxt) {
1218-
return SubroutineData {
1219-
location_counts: HashMap::with_hasher(Default::default()),
1220-
subroutine_uniforms: HashMap::with_hasher(Default::default()),
1221-
}
1218+
return Default::default();
12221219
}
12231220

12241221
let program = match program {
12251222
// subroutines not supported.
1226-
Handle::Handle(_) => return SubroutineData {
1227-
location_counts: HashMap::with_hasher(Default::default()),
1228-
subroutine_uniforms: HashMap::with_hasher(Default::default()),
1229-
},
1223+
Handle::Handle(_) => return Default::default(),
12301224
Handle::Id(id) => id
12311225
};
12321226

1227+
// Compute shader programs are not handled: #1718
1228+
let mut shader_count = 0;
1229+
ctxt.gl.GetProgramiv(program, gl::ATTACHED_SHADERS, &mut shader_count);
1230+
if shader_count < 2 {
1231+
return Default::default();
1232+
}
1233+
12331234
let shader_stages = get_shader_stages(has_geometry_shader,
12341235
has_tessellation_control_shader,
12351236
has_tessellation_evaluation_shader);

0 commit comments

Comments
 (0)