mirror of
https://github.com/rust-mobile/android-activity.git
synced 2026-07-04 05:47:26 +00:00
agdk-winit-wgpu: update to wgpu 0.13
This commit is contained in:
@@ -9,7 +9,7 @@ edition = "2021"
|
||||
log = "0.4"
|
||||
winit = { git = "https://github.com/rib/winit", branch = "android-activity-0.27"}
|
||||
#winit = { path="../../../winit" }
|
||||
wgpu = "0.12.0"
|
||||
wgpu = "0.13.0"
|
||||
pollster = "0.2"
|
||||
|
||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||
|
||||
@@ -85,7 +85,7 @@ async fn init_render_state(adapter: &Adapter, target_format: TextureFormat) -> R
|
||||
|
||||
trace!("WGPU: loading shader");
|
||||
// Load the shaders from disk
|
||||
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: None,
|
||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
||||
});
|
||||
@@ -109,7 +109,7 @@ async fn init_render_state(adapter: &Adapter, target_format: TextureFormat) -> R
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
entry_point: "fs_main",
|
||||
targets: &[target_format.into()],
|
||||
targets: &[Some(target_format.into())],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState::default(),
|
||||
depth_stencil: None,
|
||||
@@ -131,7 +131,7 @@ fn configure_surface_swapchain(render_state: &RenderState, surface_state: &Surfa
|
||||
let swapchain_format = render_state.target_format;
|
||||
let size = surface_state.window.inner_size();
|
||||
|
||||
let mut config = wgpu::SurfaceConfiguration {
|
||||
let config = wgpu::SurfaceConfiguration {
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
format: swapchain_format,
|
||||
width: size.width,
|
||||
@@ -170,8 +170,8 @@ async fn ensure_render_state_for_surface(app: &App, new_surface_state: &SurfaceS
|
||||
let adapter = app_guard.adapter.as_ref().unwrap();
|
||||
|
||||
if app_guard.render_state.is_none() {
|
||||
trace!("WGPU: finding preferred swapchain format");
|
||||
let swapchain_format = new_surface_state.surface.get_preferred_format(&adapter).unwrap();
|
||||
trace!("WGPU: finding supported swapchain format");
|
||||
let swapchain_format = new_surface_state.surface.get_supported_formats(&adapter)[0];
|
||||
|
||||
let rs = init_render_state(adapter, swapchain_format).await;
|
||||
app_guard.render_state = Some(rs);
|
||||
@@ -269,14 +269,14 @@ fn run(event_loop: EventLoop<()>, app: App) {
|
||||
{
|
||||
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: None,
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),
|
||||
store: true,
|
||||
},
|
||||
}],
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
});
|
||||
rpass.set_pipeline(&rs.render_pipeline);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[[stage(vertex)]]
|
||||
fn vs_main([[builtin(vertex_index)]] in_vertex_index: u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@vertex
|
||||
fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4<f32> {
|
||||
let x = f32(i32(in_vertex_index) - 1);
|
||||
let y = f32(i32(in_vertex_index & 1u) * 2 - 1);
|
||||
return vec4<f32>(x, y, 0.0, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn fs_main() -> [[location(0)]] vec4<f32> {
|
||||
@fragment
|
||||
fn fs_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user