Skip to content

Commit

Permalink
Merge pull request #1182 from tomaka/fix-1181
Browse files Browse the repository at this point in the history
Add a work-around for Radeon drivers crashing with 32+ texture units
  • Loading branch information
tomaka committed Aug 25, 2015
2 parents 6d7bc69 + db37e98 commit ff20c8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@
- Add support for the `GL_OES_element_index_uint` extension.
- Fixed OpenGL ES 3.2 not working.
- Add support for `IntVec{2|3|4}` and `UnsignedIntVec{2|3|4}` uniform types.
- Add a work-around for Radeon drivers crashing with 32+ texture units.

## Version 0.8.5 (2015-08-12)

Expand Down
17 changes: 17 additions & 0 deletions src/context/capabilities.rs
@@ -1,6 +1,8 @@
use context::ExtensionsList;
use version::Version;
use version::Api;
use std::cmp;
use std::ffi::CStr;
use std::mem;
use gl;

Expand Down Expand Up @@ -94,6 +96,14 @@ pub enum ReleaseBehavior {
pub unsafe fn get_capabilities(gl: &gl::Gl, version: &Version, extensions: &ExtensionsList)
-> Capabilities
{
// getting the value of `GL_RENDERER`
let renderer = unsafe {
let s = gl.GetString(gl::RENDERER);
assert!(!s.is_null());
String::from_utf8(CStr::from_ptr(s as *const i8).to_bytes().to_vec()).ok()
.expect("glGetString(GL_RENDERER) returned a non-UTF8 string")
};

Capabilities {
supported_glsl_versions: {
get_supported_glsl(gl, version, extensions)
Expand Down Expand Up @@ -253,6 +263,13 @@ pub unsafe fn get_capabilities(gl: &gl::Gl, version: &Version, extensions: &Exte
max_combined_texture_image_units: {
let mut val = 2;
gl.GetIntegerv(gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mut val);

// WORK-AROUND (issue #1181)
// Some Radeon drivers crash if you use texture units 32 or more.
if renderer.contains("Radeon") {
val = cmp::min(val, 32);
}

val
},

Expand Down

0 comments on commit ff20c8d

Please sign in to comment.