summaryrefslogtreecommitdiff
path: root/src/graphics.rs
diff options
context:
space:
mode:
authorTengu712 <genreihoutengu@gmail.com>2026-09-26 19:56:07 +0900
committerTengu712 <genreihoutengu@gmail.com>2026-09-26 19:56:07 +0900
commitb27234e27bbaf4d7f7f3467de64bd95ff2145c0e (patch)
treec80a0ef9c9a18111fb8596ae1017bdfee13750b7 /src/graphics.rs
parent25bdfbcd26901f0857c23af647f5063d6759fdcd (diff)
make it better
Diffstat (limited to 'src/graphics.rs')
-rw-r--r--src/graphics.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/graphics.rs b/src/graphics.rs
index d933c8b..6fa13b3 100644
--- a/src/graphics.rs
+++ b/src/graphics.rs
@@ -2,7 +2,7 @@ use std::{borrow::Cow, sync::Arc};
use wgpu::*;
use winit::{dpi::PhysicalSize, event_loop::OwnedDisplayHandle, window::Window};
-pub enum RenderResult {
+pub enum AcquireSurfaceTextureResult {
Ok(SurfaceTexture),
ShouldSkip,
Lost,
@@ -42,6 +42,9 @@ impl Renderer {
.map_err(|e| e.to_string())?;
let surface_cap = surface.get_capabilities(&adapter);
+ if surface_cap.formats.is_empty() {
+ return Err("no surface format found".to_string());
+ }
let (surface_format, view_format) = decide_surface_and_view_format(&adapter, &surface_cap);
@@ -110,24 +113,25 @@ impl Renderer {
Ok(v)
}
- pub fn get_current_texture(&self, window: &Window) -> RenderResult {
+ pub fn get_current_texture(&self, window: &Window) -> AcquireSurfaceTextureResult {
match self.surface.get_current_texture() {
- CurrentSurfaceTexture::Success(v) => RenderResult::Ok(v),
+ CurrentSurfaceTexture::Success(v) => AcquireSurfaceTextureResult::Ok(v),
CurrentSurfaceTexture::Suboptimal(v) => {
// NOTE: 取得したテクスチャが生存した状態でサーフェスを再設定すると
// `PreviousOutputExists`エラーになるので、
// 破棄した上で再設定し、描画をスキップする。
drop(v);
self.configure_surface(window.inner_size());
- RenderResult::ShouldSkip
+ AcquireSurfaceTextureResult::ShouldSkip
}
- CurrentSurfaceTexture::Occluded => RenderResult::ShouldSkip,
- CurrentSurfaceTexture::Timeout => RenderResult::ShouldSkip,
+ CurrentSurfaceTexture::Occluded => AcquireSurfaceTextureResult::ShouldSkip,
+ CurrentSurfaceTexture::Timeout => AcquireSurfaceTextureResult::ShouldSkip,
CurrentSurfaceTexture::Outdated => {
self.configure_surface(window.inner_size());
- RenderResult::ShouldSkip
+ AcquireSurfaceTextureResult::ShouldSkip
}
- CurrentSurfaceTexture::Lost => RenderResult::Lost,
+ CurrentSurfaceTexture::Lost => AcquireSurfaceTextureResult::Lost,
+ // TODO: 一応対応する。
CurrentSurfaceTexture::Validation => unreachable!(),
}
}
@@ -158,6 +162,8 @@ impl Renderer {
render_pass.set_pipeline(&self.pipeline);
+ // TODO: 描画
+
drop(render_pass);
self.queue.submit([encoder.finish()]);