uidev: query surface format + color space from gpu
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
use glam::{Vec2, vec2};
|
||||
use glam::{vec2, Vec2};
|
||||
use std::sync::Arc;
|
||||
use testbed::{Testbed, testbed_any::TestbedAny};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use testbed::{testbed_any::TestbedAny, Testbed};
|
||||
use tracing_subscriber::filter::LevelFilter;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use vulkan::init_window;
|
||||
use vulkano::{
|
||||
Validated, VulkanError,
|
||||
command_buffer::CommandBufferUsage,
|
||||
format::Format,
|
||||
image::{ImageUsage, view::ImageView},
|
||||
image::{view::ImageView, ImageUsage},
|
||||
swapchain::{
|
||||
CompositeAlpha, PresentMode, Surface, SurfaceInfo, Swapchain, SwapchainCreateInfo,
|
||||
SwapchainPresentInfo, acquire_next_image,
|
||||
acquire_next_image, ColorSpace, CompositeAlpha, PresentMode, Surface, SurfaceInfo, Swapchain,
|
||||
SwapchainCreateInfo, SwapchainPresentInfo,
|
||||
},
|
||||
sync::GpuFuture,
|
||||
Validated, VulkanError,
|
||||
};
|
||||
use wgui::{
|
||||
event::{MouseButtonIndex, MouseDownEvent, MouseMotionEvent, MouseUpEvent, MouseWheelEvent},
|
||||
gfx::{WGfx, cmd::WGfxClearMode},
|
||||
gfx::{cmd::WGfxClearMode, WGfx},
|
||||
renderer_vk::{self},
|
||||
};
|
||||
use winit::{
|
||||
@@ -32,7 +32,7 @@ use wlx_common::{audio, timestep::Timestep};
|
||||
use crate::{
|
||||
rate_limiter::RateLimiter,
|
||||
testbed::{
|
||||
TestbedUpdateParams, testbed_dashboard::TestbedDashboard, testbed_generic::TestbedGeneric,
|
||||
testbed_dashboard::TestbedDashboard, testbed_generic::TestbedGeneric, TestbedUpdateParams,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -74,13 +74,18 @@ fn load_testbed(audio_sample_player: &mut audio::SamplePlayer) -> anyhow::Result
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
init_logging();
|
||||
|
||||
let (gfx, event_loop, window, surface) =
|
||||
let (gfx, event_loop, window, surface, color_space) =
|
||||
init_window("[-/=]: gui scale, F10: debug draw, F11: print tree")?;
|
||||
let inner_size = window.inner_size();
|
||||
let mut swapchain_size = [inner_size.width, inner_size.height];
|
||||
|
||||
let mut swapchain_create_info =
|
||||
swapchain_create_info(&gfx, gfx.surface_format, surface.clone(), swapchain_size);
|
||||
let mut swapchain_create_info = swapchain_create_info(
|
||||
&gfx,
|
||||
gfx.surface_format,
|
||||
color_space,
|
||||
surface.clone(),
|
||||
swapchain_size,
|
||||
);
|
||||
|
||||
let (mut swapchain, mut images) = {
|
||||
let (swapchain, images) = Swapchain::new(
|
||||
@@ -400,6 +405,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn swapchain_create_info(
|
||||
graphics: &WGfx,
|
||||
format: Format,
|
||||
color_space: ColorSpace,
|
||||
surface: Arc<Surface>,
|
||||
extent: [u32; 2],
|
||||
) -> SwapchainCreateInfo {
|
||||
@@ -453,6 +459,7 @@ fn swapchain_create_info(
|
||||
image_format: format,
|
||||
image_extent: extent,
|
||||
image_usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
image_color_space: color_space,
|
||||
composite_alpha,
|
||||
..Default::default()
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use anyhow::Context;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
use vulkano::{
|
||||
device::{
|
||||
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, Queue, QueueCreateInfo, QueueFlags,
|
||||
physical::{PhysicalDevice, PhysicalDeviceType},
|
||||
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, Queue, QueueCreateInfo, QueueFlags,
|
||||
},
|
||||
instance::{Instance, InstanceCreateInfo},
|
||||
swapchain::ColorSpace,
|
||||
};
|
||||
use wgui::gfx::WGfx;
|
||||
|
||||
@@ -21,6 +23,7 @@ pub fn init_window(
|
||||
winit::event_loop::EventLoop<()>,
|
||||
Arc<winit::window::Window>,
|
||||
Arc<vulkano::swapchain::Surface>,
|
||||
ColorSpace,
|
||||
)> {
|
||||
use vulkano::{instance::InstanceCreateFlags, swapchain::Surface};
|
||||
use winit::{event_loop::EventLoop, window::Window};
|
||||
@@ -90,6 +93,12 @@ pub fn init_window(
|
||||
log::info!("img_filter_cubic!");
|
||||
}
|
||||
|
||||
let (format, color_space) = physical_device
|
||||
.surface_formats(&surface, vulkano::swapchain::SurfaceInfo::default())?
|
||||
.into_iter()
|
||||
.next()
|
||||
.context("Could not read surface formats for PhysicalDevice")?;
|
||||
|
||||
let (device, queues) = Device::new(
|
||||
physical_device,
|
||||
DeviceCreateInfo {
|
||||
@@ -113,14 +122,8 @@ pub fn init_window(
|
||||
|
||||
let (queue_gfx, queue_xfer, _) = unwrap_queues(queues.collect());
|
||||
|
||||
let me = WGfx::new_from_raw(
|
||||
instance,
|
||||
device,
|
||||
queue_gfx,
|
||||
queue_xfer,
|
||||
vulkano::format::Format::R8G8B8A8_SRGB,
|
||||
);
|
||||
Ok((me, event_loop, window, surface))
|
||||
let me = WGfx::new_from_raw(instance, device, queue_gfx, queue_xfer, format);
|
||||
Ok((me, event_loop, window, surface, color_space))
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
Reference in New Issue
Block a user