Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying minor GLES3 version #3998

Merged
merged 6 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ Bottom level categories:

## Unreleased

### Added/New Features

- Add `force_angle_gles31` field to `wgpu::InstanceDescriptor`. By @PJB3005 in [#3998](https://github.com/gfx-rs/wgpu/pull/3998)

### Changes

- Omit texture store bound checks since they are no-ops if out of bounds on all APIs. By @teoxoy in [#3975](https://github.com/gfx-rs/wgpu/pull/3975)


### Bug Fixes

#### General
Expand Down
1 change: 1 addition & 0 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ pub async fn op_webgpu_request_adapter(
wgpu_types::InstanceDescriptor {
backends,
dx12_shader_compiler: wgpu_types::Dx12Compiler::Fxc,
force_angle_gles31: false
},
)));
state.borrow::<Instance>()
Expand Down
1 change: 1 addition & 0 deletions examples/capture/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async fn create_red_image_with_dimensions(
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends,
dx12_shader_compiler: wgpu::Dx12Compiler::default(),
force_angle_gles31: false,
});
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions::default())
Expand Down
1 change: 1 addition & 0 deletions examples/common/src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ async fn setup<E: Example>(title: &str) -> Setup {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends,
dx12_shader_compiler,
force_angle_gles31: false,
});
let (size, surface) = unsafe {
let size = window.inner_size();
Expand Down
1 change: 1 addition & 0 deletions player/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl Corpus {
wgt::InstanceDescriptor {
backends: corpus.backends,
dx12_shader_compiler: wgt::Dx12Compiler::Fxc,
force_angle_gles31: false,
},
);
for &backend in BACKENDS {
Expand Down
1 change: 1 addition & 0 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ fn initialize_adapter() -> (Adapter, SurfaceGuard) {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends,
dx12_shader_compiler,
force_angle_gles31: true,
});
let surface_guard;
let compatible_surface;
Expand Down
2 changes: 2 additions & 0 deletions tests/tests/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ fn initialize() {
let _ = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all),
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
force_angle_gles31: false,
});
}

fn request_adapter_inner(power: wgt::PowerPreference) {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all),
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
force_angle_gles31: false,
});

let _adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl Instance {
name: "wgpu",
flags,
dx12_shader_compiler: instance_desc.dx12_shader_compiler.clone(),
force_angle_gles31: instance_desc.force_angle_gles31,
};
unsafe { hal::Instance::init(&hal_desc).ok() }
} else {
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/examples/halmark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl<A: hal::Api> Example<A> {
},
// Can't rely on having DXC available, so use FXC instead
dx12_shader_compiler: wgt::Dx12Compiler::Fxc,
force_angle_gles31: false,
};
let instance = unsafe { A::Instance::init(&instance_desc)? };
let mut surface = unsafe {
Expand Down
13 changes: 10 additions & 3 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ impl Inner {
flags: crate::InstanceFlags,
egl: Arc<EglInstance>,
display: khronos_egl::Display,
angle_force_gles31: bool,
) -> Result<Self, crate::InstanceError> {
let version = egl.initialize(display).map_err(|_| crate::InstanceError)?;
let vendor = egl
Expand Down Expand Up @@ -542,9 +543,15 @@ impl Inner {

//TODO: make it so `Device` == EGL Context
let mut context_attributes = vec![
khronos_egl::CONTEXT_CLIENT_VERSION,
khronos_egl::CONTEXT_MAJOR_VERSION,
3, // Request GLES 3.0 or higher
];

if angle_force_gles31 {
context_attributes.push(khronos_egl::CONTEXT_MINOR_VERSION);
context_attributes.push(1);
}

if flags.contains(crate::InstanceFlags::DEBUG) {
if version >= (1, 5) {
log::info!("\tEGL context: +debug");
Expand Down Expand Up @@ -836,7 +843,7 @@ impl crate::Instance<super::Api> for Instance {
unsafe { (function)(Some(egl_debug_proc), attributes.as_ptr()) };
}

let inner = Inner::create(desc.flags, egl, display)?;
let inner = Inner::create(desc.flags, egl, display, desc.force_angle_gles31)?;

Ok(Instance {
wsi: WindowSystemInterface {
Expand Down Expand Up @@ -919,7 +926,7 @@ impl crate::Instance<super::Api> for Instance {
.unwrap();

let new_inner =
Inner::create(self.flags, Arc::clone(&inner.egl.instance), display)
Inner::create(self.flags, Arc::clone(&inner.egl.instance), display, false)
.map_err(|_| crate::InstanceError)?;

let old_inner = std::mem::replace(inner.deref_mut(), new_inner);
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ pub struct InstanceDescriptor<'a> {
pub name: &'a str,
pub flags: InstanceFlags,
pub dx12_shader_compiler: wgt::Dx12Compiler,
pub force_angle_gles31: bool,
}

#[derive(Clone, Debug)]
Expand Down
3 changes: 3 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6322,13 +6322,16 @@ pub struct InstanceDescriptor {
pub backends: Backends,
/// Which DX12 shader compiler to use.
pub dx12_shader_compiler: Dx12Compiler,
/// Force ANGLE to support GLES 3.1, even on nonconformant implementations like D3D11.
pub force_angle_gles31: bool,
PJB3005 marked this conversation as resolved.
Show resolved Hide resolved
}

impl Default for InstanceDescriptor {
fn default() -> Self {
Self {
backends: Backends::all(),
dx12_shader_compiler: Dx12Compiler::default(),
force_angle_gles31: false,
}
}
}
Expand Down