summaryrefslogtreecommitdiff
path: root/render/src/renderer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'render/src/renderer.rs')
-rw-r--r--render/src/renderer.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/render/src/renderer.rs b/render/src/renderer.rs
index f5b486d..4b4f60d 100644
--- a/render/src/renderer.rs
+++ b/render/src/renderer.rs
@@ -4,7 +4,6 @@ use std::{convert::TryInto, sync::Arc};
use crate::{
vertex::SQUARE, Camera, Instance, InstanceBuffer, RenderWindowConfig, TextureAtlas, Vertex,
};
-use alligator_resources::texture::TextureManager;
use pollster::FutureExt;
use thiserror::Error;
use wgpu::{include_wgsl, util::DeviceExt};
@@ -90,7 +89,7 @@ fn get_adapter(
let adapter = adapter.or_else(|| {
instance
- .enumerate_adapters(wgpu::Backends::PRIMARY)
+ .enumerate_adapters(wgpu::Backends::VULKAN)
.find(|adapter| !surface.get_capabilities(adapter).formats.is_empty())
});
@@ -148,20 +147,14 @@ impl Renderer {
/// panic on some platforms.
// TODO make it possible to use without a window (ie, use a bitmap in memory as a surface)
// TODO this function needs to be smaller
- pub fn new(
- config: &RenderWindowConfig,
- textures: Arc<TextureManager>,
- ) -> Result<Self, NewRendererError> {
+ pub fn new(config: &RenderWindowConfig) -> Result<Self, NewRendererError> {
// build the window
let event_loop = EventLoop::new();
let window = config.to_window().build(&event_loop)?;
let event_loop = Some(event_loop);
// the instance's main purpose is to create an adapter and a surface
- let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
- backends: wgpu::Backends::VULKAN,
- dx12_shader_compiler: wgpu::Dx12Compiler::Fxc, // TODO support DXC
- });
+ let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
// the surface is the part of the screen we'll draw to
let surface =
@@ -220,7 +213,6 @@ impl Renderer {
// TODO make this configurable
let (textures, texture_layout) = TextureAtlas::new(
&device,
- textures,
window.inner_size().width,
window.inner_size().height,
);
@@ -311,7 +303,7 @@ impl Renderer {
}
/// Get a reference to the texture atlas
- pub const fn textures(&self) -> &TextureAtlas {
+ pub const fn texture_atlas(&self) -> &TextureAtlas {
&self.textures
}
@@ -358,10 +350,12 @@ impl Renderer {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
- store: true,
+ store: wgpu::StoreOp::Discard,
},
})],
depth_stencil_attachment: None,
+ timestamp_writes: None,
+ occlusion_query_set: None,
});
render_pass.set_pipeline(&self.render_pipeline);
@@ -421,7 +415,7 @@ impl Renderer {
// https://github.com/gfx-rs/wgpu/issues/1783#issuecomment-1328463201
if self.window.inner_size().width != 0 && self.window.inner_size().height != 0 {
match self.render() {
- Ok(_) => {}
+ Ok(()) => {}
// reconfigure the surface if it's been lost
Err(wgpu::SurfaceError::Lost) => {
self.reconfigure();