Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Add override for max_texture_dimension_2d
Browse files Browse the repository at this point in the history
  • Loading branch information
darthdeus committed Apr 29, 2024
1 parent f7673ce commit ca87707
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
- Upgraded `wgpu: 0.18 -> 0.19.3, winit: 0.28 -> 0.29, egui: 0.24 -> 0.26`.
- Made `wgpu::PowerPreference` configurable & default to `None`, with the hope of fixing a potential
issue where users have their dedicated GPU disabled on a dual GPU setup.
- Add option to override `max_texture_dimension_2d` in `GameConfig`, this is useful for games that want to support
resolutions higher than 4K. It's not entirely clear to me whether we can safely just raise this and still work
on all machines, hence why it becomes an optional override. We're doing some more testing on this in our
game, and if it'll be safe we'll also change the default.

# v0.3.0

Expand Down
4 changes: 4 additions & 0 deletions comfy-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub struct GameConfig {
pub resolution: ResolutionConfig,
pub min_resolution: ResolutionConfig,

pub max_texture_dimension_2d_override: Option<u32>,

/// Overrides `wgpu`'s power preference for adapter selection. Should work around
/// a potential issue where when selecting `wgpu::PowerPreference::HighPerformance` is on
/// and the user has a laptop with a dual GPU setup where the dedicated GPU is not enabled,
Expand Down Expand Up @@ -141,6 +143,8 @@ impl Default for GameConfig {
game_name: "TODO_GAME_NAME".to_string(),
version: "TODO_VERSION",

max_texture_dimension_2d_override: None,

resolution,
min_resolution,

Expand Down
7 changes: 5 additions & 2 deletions comfy-wgpu/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ pub async fn create_graphics_context(

trace!("Requesting device");

let max_texture_dim_2d =
game_config().max_texture_dimension_2d_override.unwrap_or(4096);

#[cfg(not(target_arch = "wasm32"))]
let limits = wgpu::Limits {
max_texture_dimension_2d: 4096,
max_texture_dimension_2d: max_texture_dim_2d,
..wgpu::Limits::downlevel_defaults()
};

#[cfg(target_arch = "wasm32")]
let limits = wgpu::Limits {
max_texture_dimension_2d: 4096,
max_texture_dimension_2d: max_texture_dim_2d,
..wgpu::Limits::downlevel_webgl2_defaults()
};

Expand Down

0 comments on commit ca87707

Please sign in to comment.