Skip to content

Commit

Permalink
Remove expected failure for OpenGL Non-ES, add comment explaining FRA…
Browse files Browse the repository at this point in the history
…MEBUFFER_SRGB, add driver info to AdapterInfo
  • Loading branch information
valaphee committed Apr 8, 2024
1 parent fdfbafe commit 813cf03
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
14 changes: 9 additions & 5 deletions tests/tests/clear_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,15 @@ static CLEAR_TEXTURE_UNCOMPRESSED: GpuTestConfiguration = GpuTestConfiguration::
.parameters(
TestParameters::default()
.expect_fail(
FailureCase::backend(wgpu::Backends::GL)
.panic("texture with format Rg8Snorm was not fully cleared")
.panic("texture with format Rgb9e5Ufloat was not fully cleared")
.validation_error("GL_INVALID_FRAMEBUFFER_OPERATION")
.validation_error("GL_INVALID_OPERATION"),
FailureCase {
backends: Some(wgpu::Backends::GL),
driver: Some("OpenGL ES"),
..FailureCase::default()
}
.panic("texture with format Rg8Snorm was not fully cleared")
.panic("texture with format Rgb9e5Ufloat was not fully cleared")
.validation_error("GL_INVALID_FRAMEBUFFER_OPERATION")
.validation_error("GL_INVALID_OPERATION"),
)
.features(wgpu::Features::CLEAR_TEXTURE),
)
Expand Down
28 changes: 24 additions & 4 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl super::Adapter {
}
}

fn make_info(vendor_orig: String, renderer_orig: String) -> wgt::AdapterInfo {
fn make_info(vendor_orig: String, renderer_orig: String, version: String) -> wgt::AdapterInfo {
let vendor = vendor_orig.to_lowercase();
let renderer = renderer_orig.to_lowercase();

Expand Down Expand Up @@ -178,13 +178,33 @@ impl super::Adapter {
0
};

let driver;
let driver_info;
if version.starts_with("WebGL ") || version.starts_with("OpenGL ") {
let es_sig = " ES";
match version.find(es_sig) {
Some(pos) => {
driver = version[..pos + es_sig.len()].to_owned();
driver_info = version[pos + es_sig.len() + 1..].to_owned();
}
None => {
let pos = version.find(' ').unwrap();
driver = version[..pos].to_owned();
driver_info = version[pos + 1..].to_owned();
}
}
} else {
driver = "OpenGL".to_owned();
driver_info = version;
}

wgt::AdapterInfo {
name: renderer_orig,
vendor: vendor_id,
device: 0,
device_type: inferred_device_type,
driver: String::new(),
driver_info: String::new(),
driver,
driver_info,
backend: wgt::Backend::Gl,
}
}
Expand Down Expand Up @@ -799,7 +819,7 @@ impl super::Adapter {
es: es_ver.is_some(),
}),
},
info: Self::make_info(vendor, renderer),
info: Self::make_info(vendor, renderer, version),
features,
capabilities: crate::Capabilities {
limits,
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ impl crate::Instance<super::Api> for Instance {
})
};

// In contract with OpenGL ES, OpenGL requires explicitly enabling sRGB conversions,
// as otherwise the user has to do the sRGB conversion.
if !matches!(inner.srgb_kind, SrgbFrameBufferKind::None) {
unsafe { gl.enable(glow::FRAMEBUFFER_SRGB) };
}
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/gles/wgl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ impl crate::Instance<super::Api> for Instance {
.supported_extensions()
.contains("GL_ARB_framebuffer_sRGB");

// In contract with OpenGL ES, OpenGL requires explicitly enabling sRGB conversions,
// as otherwise the user has to do the sRGB conversion.
if srgb_capable {
unsafe { gl.enable(glow::FRAMEBUFFER_SRGB) };
}
Expand Down

0 comments on commit 813cf03

Please sign in to comment.