Skip to content

Commit

Permalink
refactor: ⬆️ Update wgpu
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Feb 12, 2025
1 parent bfbad44 commit 121177b
Show file tree
Hide file tree
Showing 8 changed files with 700 additions and 440 deletions.
1,053 changes: 658 additions & 395 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion alvr/dashboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tungstenite = "0.24"
ureq = { version = "2", features = ["json"] }

[target.'cfg(target_os = "linux")'.dependencies]
wgpu = "0.20"
wgpu = "24"
libva = { package = "cros-libva", version = "0.0.7" }
nvml-wrapper = "0.10.0"

Expand Down
6 changes: 2 additions & 4 deletions alvr/dashboard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ fn main() {

#[cfg(target_os = "linux")]
{
let has_nvidia = wgpu::Instance::new(wgpu::InstanceDescriptor {
let has_nvidia = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends: wgpu::Backends::VULKAN,
flags: wgpu::InstanceFlags::empty(),
dx12_shader_compiler: Default::default(),
gles_minor_version: Default::default(),
..Default::default()
})
.enumerate_adapters(wgpu::Backends::VULKAN)
.iter()
Expand Down
6 changes: 2 additions & 4 deletions alvr/dashboard/src/steamvr_launcher/linux_steamvr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ enum DeviceInfo {
}

pub fn linux_hardware_checks() {
let wgpu_adapters = wgpu::Instance::new(wgpu::InstanceDescriptor {
let wgpu_adapters = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends: wgpu::Backends::VULKAN,
flags: wgpu::InstanceFlags::empty(),
dx12_shader_compiler: Default::default(),
gles_minor_version: Default::default(),
..Default::default()
})
.enumerate_adapters(wgpu::Backends::VULKAN);
let device_infos = wgpu_adapters
Expand Down
6 changes: 3 additions & 3 deletions alvr/graphics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ license.workspace = true
alvr_common.workspace = true
alvr_session.workspace = true

glow = "0.13"
glow = "0.16"
glyph_brush_layout = "0.2"
khronos-egl = { version = "6", features = ["dynamic"] }
pollster = "0.3"
wgpu = "0.20"
wgpu-core = { version = "0.21", features = ["gles"] }
wgpu = "24"
wgpu-core = { version = "24", features = ["gles"] }
43 changes: 21 additions & 22 deletions alvr/graphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,23 @@ fn create_texture_from_gles(
};

unsafe {
let hal_texture = device
.as_hal::<api::Gles, _, _>(|device| {
device.unwrap().texture_from_raw(
NonZeroU32::new(texture).unwrap(),
&hal::TextureDescriptor {
label: None,
size,
mip_level_count: 1,
sample_count: 1,
dimension: TextureDimension::D2,
format,
usage: TextureUses::COLOR_TARGET,
memory_flags: MemoryFlags::empty(),
view_formats: vec![],
},
Some(Box::new(())),
)
})
.unwrap();
let hal_texture = device.as_hal::<api::Gles, _, _>(|device| {
device.unwrap().texture_from_raw(
NonZeroU32::new(texture).unwrap(),
&hal::TextureDescriptor {
label: None,
size,
mip_level_count: 1,
sample_count: 1,
dimension: TextureDimension::D2,
format,
usage: TextureUses::COLOR_TARGET,
memory_flags: MemoryFlags::empty(),
view_formats: vec![],
},
Some(Box::new(|| ())),
)
});

device.create_texture_from_hal::<api::Gles>(
hal_texture,
Expand Down Expand Up @@ -216,6 +214,7 @@ impl GraphicsContext {
use std::mem;
use wgpu::{
Backends, DeviceDescriptor, Features, InstanceDescriptor, InstanceFlags, Limits,
MemoryHints,
};

const CREATE_IMAGE_FN_STR: &str = "eglCreateImageKHR";
Expand All @@ -229,11 +228,10 @@ impl GraphicsContext {
InstanceFlags::empty()
};

let instance = Instance::new(InstanceDescriptor {
let instance = Instance::new(&InstanceDescriptor {
backends: Backends::GL,
flags,
dx12_shader_compiler: Default::default(),
gles_minor_version: Default::default(),
backend_options: Default::default(),
});

let adapter = instance.enumerate_adapters(Backends::GL).remove(0);
Expand All @@ -245,6 +243,7 @@ impl GraphicsContext {
max_push_constant_size: MAX_PUSH_CONSTANTS_SIZE,
..adapter.limits()
},
memory_hints: MemoryHints::Performance,
},
None,
))
Expand Down
19 changes: 10 additions & 9 deletions alvr/graphics/src/lobby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use wgpu::{
include_wgsl, BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout,
BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendComponent,
BlendFactor, BlendOperation, BlendState, Color, ColorTargetState, ColorWrites,
CommandEncoderDescriptor, Device, Extent3d, FilterMode, FragmentState, ImageCopyTexture,
ImageDataLayout, LoadOp, Operations, Origin3d, PipelineLayoutDescriptor, PrimitiveState,
PrimitiveTopology, PushConstantRange, RenderPass, RenderPassColorAttachment,
RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, SamplerBindingType,
SamplerDescriptor, ShaderModuleDescriptor, ShaderStages, StoreOp, Texture, TextureAspect,
CommandEncoderDescriptor, Device, Extent3d, FilterMode, FragmentState, LoadOp, Operations,
Origin3d, PipelineLayoutDescriptor, PrimitiveState, PrimitiveTopology, PushConstantRange,
RenderPass, RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline,
RenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor, ShaderModuleDescriptor,
ShaderStages, StoreOp, TexelCopyBufferLayout, TexelCopyTextureInfo, Texture, TextureAspect,
TextureSampleType, TextureView, TextureViewDimension, VertexState,
};

Expand Down Expand Up @@ -180,7 +180,7 @@ fn create_pipeline(
})),
vertex: VertexState {
module: &shader_module,
entry_point: "vertex_main",
entry_point: None,
compilation_options: Default::default(),
buffers: &[],
},
Expand All @@ -192,7 +192,7 @@ fn create_pipeline(
multisample: Default::default(),
fragment: Some(FragmentState {
module: &shader_module,
entry_point: "fragment_main",
entry_point: None,
compilation_options: Default::default(),
targets: &[Some(ColorTargetState {
format: SDR_FORMAT,
Expand All @@ -212,6 +212,7 @@ fn create_pipeline(
})],
}),
multiview: None,
cache: None,
})
}

Expand Down Expand Up @@ -384,14 +385,14 @@ impl LobbyRenderer {
}

self.context.queue.write_texture(
ImageCopyTexture {
TexelCopyTextureInfo {
texture: &self.hud_texture,
mip_level: 0,
origin: Origin3d::ZERO,
aspect: TextureAspect::All,
},
&buffer,
ImageDataLayout {
TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(HUD_TEXTURE_SIDE as u32 * 4),
rows_per_image: Some(HUD_TEXTURE_SIDE as u32),
Expand Down
5 changes: 3 additions & 2 deletions alvr/graphics/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl StreamRenderer {
})),
vertex: VertexState {
module: &shader_module,
entry_point: "vertex_main",
entry_point: None,
compilation_options: PipelineCompilationOptions {
constants: &constants,
zero_initialize_workgroup_memory: false,
Expand All @@ -143,7 +143,7 @@ impl StreamRenderer {
multisample: Default::default(),
fragment: Some(FragmentState {
module: &shader_module,
entry_point: "fragment_main",
entry_point: None,
compilation_options: PipelineCompilationOptions {
constants: &constants,
zero_initialize_workgroup_memory: false,
Expand All @@ -155,6 +155,7 @@ impl StreamRenderer {
})],
}),
multiview: None,
cache: None,
});

let sampler = device.create_sampler(&SamplerDescriptor {
Expand Down

0 comments on commit 121177b

Please sign in to comment.