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

Add support for running on OpenGL 4.1 with a core profile on macOS #5331

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ By @cwfitzgerald in [#5325](https://github.com/gfx-rs/wgpu/pull/5325).
- Refactor tests to read feature flags by name instead of a hardcoded hexadecimal u64. By @rodolphito in [#5155](https://github.com/gfx-rs/wgpu/pull/5155).
- Add test that verifies that we can drop the queue before using the device to create a command encoder. By @Davidster in [#5211](https://github.com/gfx-rs/wgpu/pull/5211)

#### GLES

- Fixes for being able to use an OpenGL 4.1 core context provided by macOS with wgpu. By @bes in [#5331](https://github.com/gfx-rs/wgpu/pull/5331).

## v0.19.0 (2024-01-17)

This release includes:
Expand Down
25 changes: 21 additions & 4 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,19 @@ impl super::Adapter {
max_push_constant_size: super::MAX_PUSH_CONSTANTS as u32 * 4,
min_uniform_buffer_offset_alignment,
min_storage_buffer_offset_alignment,
max_inter_stage_shader_components: unsafe {
gl.get_parameter_i32(glow::MAX_VARYING_COMPONENTS)
} as u32,
max_inter_stage_shader_components: {
// MAX_VARYING_COMPONENTS may return 0, because it is deprecated since OpenGL 3.2 core,
// and an OpenGL Context with the core profile and with forward-compatibility=true,
// will make deprecated constants unavailable.
let max_varying_components =
unsafe { gl.get_parameter_i32(glow::MAX_VARYING_COMPONENTS) } as u32;
if max_varying_components == 0 {
// default value for max_inter_stage_shader_components
60
} else {
max_varying_components
}
},
max_color_attachments,
max_color_attachment_bytes_per_sample,
max_compute_workgroup_storage_size: if supports_work_group_params {
Expand Down Expand Up @@ -837,7 +847,14 @@ impl super::Adapter {
let source = if es {
format!("#version 300 es\nprecision lowp float;\n{source}")
} else {
format!("#version 130\n{source}")
let version = gl.version();
if version.major == 3 && version.minor == 0 {
// OpenGL 3.0 only supports this format
format!("#version 130\n{source}")
} else {
// OpenGL 3.1+ support this format
format!("#version 140\n{source}")
}
};
let shader = unsafe { gl.create_shader(shader_type) }.expect("Could not create shader");
unsafe { gl.shader_source(shader, &source) };
Expand Down
Loading