no hard dep on winit window for renderers
This commit is contained in:
parent
1f71402915
commit
ae9c35ed9a
4 changed files with 37 additions and 17 deletions
|
@ -1,7 +1,9 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use pixels::{Pixels, SurfaceTexture};
|
use pixels::{
|
||||||
use winit::window::Window;
|
raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle},
|
||||||
|
Pixels, SurfaceTexture,
|
||||||
|
};
|
||||||
|
|
||||||
use super::ResolutionData;
|
use super::ResolutionData;
|
||||||
|
|
||||||
|
@ -20,9 +22,9 @@ pub struct RendererBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RendererBackend {
|
impl RendererBackend {
|
||||||
pub fn new(
|
pub fn new<W: HasRawDisplayHandle + HasRawWindowHandle>(
|
||||||
resolutions: ResolutionData,
|
resolutions: ResolutionData,
|
||||||
window: &Window,
|
window: &W,
|
||||||
_: WindowOptions,
|
_: WindowOptions,
|
||||||
_: Arc<RendererBackendManager>,
|
_: Arc<RendererBackendManager>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -31,7 +33,11 @@ impl RendererBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(&mut self, resolutions: ResolutionData, window: &Window) {
|
pub fn resize<W: HasRawDisplayHandle + HasRawWindowHandle>(
|
||||||
|
&mut self,
|
||||||
|
resolutions: ResolutionData,
|
||||||
|
window: &W,
|
||||||
|
) {
|
||||||
self.pixels = new_pixels(resolutions, window);
|
self.pixels = new_pixels(resolutions, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +52,11 @@ impl RendererBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_pixels(resolutions: ResolutionData, window: &Window) -> Pixels {
|
fn new_pixels<W: HasRawDisplayHandle + HasRawWindowHandle>(
|
||||||
let surface_texture: SurfaceTexture<'_, Window> =
|
resolutions: ResolutionData,
|
||||||
|
window: &W,
|
||||||
|
) -> Pixels {
|
||||||
|
let surface_texture: SurfaceTexture<'_, W> =
|
||||||
SurfaceTexture::new(resolutions.real_width, resolutions.real_height, window);
|
SurfaceTexture::new(resolutions.real_width, resolutions.real_height, window);
|
||||||
pixels::PixelsBuilder::new(
|
pixels::PixelsBuilder::new(
|
||||||
resolutions.scaled_width,
|
resolutions.scaled_width,
|
||||||
|
|
|
@ -3,7 +3,6 @@ use ash::{
|
||||||
vk, Device,
|
vk, Device,
|
||||||
};
|
};
|
||||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||||
use winit::window::Window;
|
|
||||||
|
|
||||||
use crate::window::ResolutionData;
|
use crate::window::ResolutionData;
|
||||||
|
|
||||||
|
@ -217,7 +216,10 @@ pub(super) struct SurfaceData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SurfaceData {
|
impl SurfaceData {
|
||||||
pub(super) unsafe fn new(window: &Window, manager: &RendererBackendManager) -> Self {
|
pub(super) unsafe fn new<W: HasRawDisplayHandle + HasRawWindowHandle>(
|
||||||
|
window: &W,
|
||||||
|
manager: &RendererBackendManager,
|
||||||
|
) -> Self {
|
||||||
let surface = ash_window::create_surface(
|
let surface = ash_window::create_surface(
|
||||||
&manager.entry,
|
&manager.entry,
|
||||||
&manager.instance,
|
&manager.instance,
|
||||||
|
|
|
@ -3,8 +3,7 @@ use std::{mem, path::PathBuf, sync::Arc};
|
||||||
use ash::{util::Align, vk, Entry, Instance};
|
use ash::{util::Align, vk, Entry, Instance};
|
||||||
use ash_window::enumerate_required_extensions;
|
use ash_window::enumerate_required_extensions;
|
||||||
use librashader::runtime::vk::{FilterChain, FilterChainOptions, FrameOptions, VulkanObjects};
|
use librashader::runtime::vk::{FilterChain, FilterChainOptions, FrameOptions, VulkanObjects};
|
||||||
use raw_window_handle::RawDisplayHandle;
|
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle};
|
||||||
use winit::window::Window;
|
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
types::{FramebufferData, SurfaceData, SwapchainData, Vertex, VulkanData, SHADER_INPUT_FORMAT},
|
types::{FramebufferData, SurfaceData, SwapchainData, Vertex, VulkanData, SHADER_INPUT_FORMAT},
|
||||||
|
@ -88,9 +87,9 @@ pub struct WindowOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RendererBackend {
|
impl RendererBackend {
|
||||||
pub fn new(
|
pub fn new<W: HasRawDisplayHandle + HasRawWindowHandle>(
|
||||||
resolutions: ResolutionData,
|
resolutions: ResolutionData,
|
||||||
window: &Window,
|
window: &W,
|
||||||
options: WindowOptions,
|
options: WindowOptions,
|
||||||
manager: Arc<RendererBackendManager>,
|
manager: Arc<RendererBackendManager>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -121,7 +120,11 @@ impl RendererBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(&mut self, resolutions: ResolutionData, _window: &Window) {
|
pub fn resize<W: HasRawDisplayHandle + HasRawWindowHandle>(
|
||||||
|
&mut self,
|
||||||
|
resolutions: ResolutionData,
|
||||||
|
_window: &W,
|
||||||
|
) {
|
||||||
unsafe { self.inner.resize(resolutions, self.manager.as_ref()) };
|
unsafe { self.inner.resize(resolutions, self.manager.as_ref()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,9 +155,9 @@ struct VulkanWindowInner {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VulkanWindowInner {
|
impl VulkanWindowInner {
|
||||||
unsafe fn new(
|
unsafe fn new<W: HasRawDisplayHandle + HasRawWindowHandle>(
|
||||||
resolutions: ResolutionData,
|
resolutions: ResolutionData,
|
||||||
window: &Window,
|
window: &W,
|
||||||
manager: &RendererBackendManager,
|
manager: &RendererBackendManager,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let surface = SurfaceData::new(window, manager);
|
let surface = SurfaceData::new(window, manager);
|
||||||
|
|
|
@ -12,7 +12,11 @@ use gb_emu_lib::{
|
||||||
};
|
};
|
||||||
use keyboard_types::{Code, KeyState};
|
use keyboard_types::{Code, KeyState};
|
||||||
use nih_plug::prelude::*;
|
use nih_plug::prelude::*;
|
||||||
use pixels::{wgpu::PowerPreference, Pixels, SurfaceTexture};
|
use pixels::{
|
||||||
|
raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle},
|
||||||
|
wgpu::PowerPreference,
|
||||||
|
Pixels, SurfaceTexture,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{Frame, FrameReceiver, JoypadInfo, JoypadSender};
|
use crate::{Frame, FrameReceiver, JoypadInfo, JoypadSender};
|
||||||
|
|
||||||
|
@ -100,6 +104,8 @@ impl EmulatorWindow {
|
||||||
frame_receiver: Arc<FrameReceiver>,
|
frame_receiver: Arc<FrameReceiver>,
|
||||||
joypad_sender: Arc<JoypadSender>,
|
joypad_sender: Arc<JoypadSender>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
window.raw_window_handle();
|
||||||
|
window.raw_display_handle();
|
||||||
let info = WindowInfo::from_logical_size(
|
let info = WindowInfo::from_logical_size(
|
||||||
Size::new(WIDTH as f64, HEIGHT as f64),
|
Size::new(WIDTH as f64, HEIGHT as f64),
|
||||||
EXTRA_SCALE as f64,
|
EXTRA_SCALE as f64,
|
||||||
|
|
Loading…
Add table
Reference in a new issue