| 131 | } |
| 132 | |
| 133 | pub fn op_webgpu_surface_get_current_texture( |
| 134 | state: &mut OpState, |
| 135 | args: SurfacePreferredFormatArgs, |
| 136 | _: (), |
| 137 | ) -> Result<ResourceId, AnyError> { |
| 138 | let surface = state.resource_table.get::<WebGpuSurface>(args.surface_rid)?; |
| 139 | let adapter = state.resource_table.get::<WebGpuAdapter>(args.adapter_rid)?; |
| 140 | let instance = state.borrow::<Instance>(); |
| 141 | |
| 142 | let current_texture = gfx_select!( |
| 143 | adapter.0 => instance.surface_get_current_texture(surface.0, std::marker::PhantomData) |
| 144 | )?; |
| 145 | if let Some(texture) = current_texture.texture_id { |
| 146 | Ok(state.resource_table.add(WebGpuTexture(texture))) |
| 147 | } else { |
| 148 | Err(anyhow!("No texture, status: {:?}", current_texture.status)) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | pub fn op_webgpu_surface_present( |
| 153 | state: &mut OpState, |