From 443fa20d22349c3d761bf93ddf044499c941a839 Mon Sep 17 00:00:00 2001 From: chyyran Date: Wed, 25 Sep 2024 20:59:01 -0400 Subject: [PATCH] test: clean up imports and features --- librashader-test/Cargo.toml | 3 +++ librashader-test/src/render/d3d11.rs | 2 +- librashader-test/src/render/d3d9.rs | 13 ++++++------- librashader-test/src/render/gl/mod.rs | 4 ++-- librashader-test/src/render/mod.rs | 16 ++++++++-------- librashader-test/src/render/mtl.rs | 2 +- librashader-test/src/render/vk/base.rs | 3 --- librashader-test/src/render/vk/mod.rs | 4 ++-- librashader-test/src/render/vk/util.rs | 5 ----- librashader-test/src/render/wgpu.rs | 4 ++-- 10 files changed, 25 insertions(+), 31 deletions(-) diff --git a/librashader-test/Cargo.toml b/librashader-test/Cargo.toml index 870af0d..4f1db18 100644 --- a/librashader-test/Cargo.toml +++ b/librashader-test/Cargo.toml @@ -23,6 +23,9 @@ glfw = { workspace = true, optional = true } ash = { workspace = true, optional = true } [features] +default = ["full"] + +full = ["vulkan", "opengl", "wgpu", "d3d9", "d3d11", "d3d12", "metal"] vulkan = ["librashader/runtime-vk", "dep:ash"] opengl = ["librashader/runtime-gl", "dep:glow", "dep:glfw"] wgpu = ["librashader/runtime-wgpu", "dep:wgpu", "dep:wgpu-types"] diff --git a/librashader-test/src/render/d3d11.rs b/librashader-test/src/render/d3d11.rs index 8a4572f..83c6968 100644 --- a/librashader-test/src/render/d3d11.rs +++ b/librashader-test/src/render/d3d11.rs @@ -13,7 +13,7 @@ impl RenderTest for Direct3D11 { Direct3D11::new(path) } - fn render(&self, path: impl AsRef, frame_count: usize) -> anyhow::Result { + fn render(&mut self, path: impl AsRef, frame_count: usize) -> anyhow::Result { let (renderbuffer, rtv) = self.create_renderbuffer(self.image_bytes.size)?; unsafe { diff --git a/librashader-test/src/render/d3d9.rs b/librashader-test/src/render/d3d9.rs index 2a3fc33..7fdaf72 100644 --- a/librashader-test/src/render/d3d9.rs +++ b/librashader-test/src/render/d3d9.rs @@ -3,16 +3,15 @@ use anyhow::anyhow; use image::RgbaImage; use librashader::runtime::d3d9::{FilterChain, FilterChainOptions}; use librashader::runtime::Viewport; -use librashader_runtime::image::{Image, PixelFormat, UVDirection, ARGB8, BGRA8}; +use librashader_runtime::image::{Image, PixelFormat, UVDirection, BGRA8}; use std::path::Path; use windows::Win32::Foundation::{HWND, TRUE}; use windows::Win32::Graphics::Direct3D9::{ Direct3DCreate9, IDirect3D9, IDirect3DDevice9, IDirect3DTexture9, D3DADAPTER_DEFAULT, - D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8, D3DFMT_R8G8B8, - D3DFMT_UNKNOWN, D3DLOCKED_RECT, D3DPOOL_DEFAULT, D3DPOOL_MANAGED, D3DPOOL_SCRATCH, - D3DPOOL_SYSTEMMEM, D3DPRESENT_INTERVAL_IMMEDIATE, D3DPRESENT_PARAMETERS, D3DRS_CLIPPING, - D3DRS_CULLMODE, D3DRS_LIGHTING, D3DRS_ZENABLE, D3DRS_ZFUNC, D3DSURFACE_DESC, - D3DSWAPEFFECT_DISCARD, D3DUSAGE_DYNAMIC, D3DUSAGE_RENDERTARGET, D3D_SDK_VERSION, + D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8, D3DLOCKED_RECT, + D3DPOOL_DEFAULT, D3DPOOL_MANAGED, D3DPOOL_SYSTEMMEM, D3DPRESENT_INTERVAL_IMMEDIATE, + D3DPRESENT_PARAMETERS, D3DSURFACE_DESC, D3DSWAPEFFECT_DISCARD, D3DUSAGE_RENDERTARGET, + D3D_SDK_VERSION, }; pub struct Direct3D9 { @@ -30,7 +29,7 @@ impl RenderTest for Direct3D9 { Direct3D9::new(path) } - fn render(&self, path: impl AsRef, frame_count: usize) -> anyhow::Result { + fn render(&mut self, path: impl AsRef, frame_count: usize) -> anyhow::Result { unsafe { let mut filter_chain = FilterChain::load_from_path( path, diff --git a/librashader-test/src/render/gl/mod.rs b/librashader-test/src/render/gl/mod.rs index c4c60ec..6713465 100644 --- a/librashader-test/src/render/gl/mod.rs +++ b/librashader-test/src/render/gl/mod.rs @@ -29,7 +29,7 @@ impl RenderTest for OpenGl3 { OpenGl3::new(path) } - fn render(&self, path: impl AsRef, frame_count: usize) -> anyhow::Result { + fn render(&mut self, path: impl AsRef, frame_count: usize) -> anyhow::Result { let mut filter_chain = unsafe { FilterChain::load_from_path( path, @@ -55,7 +55,7 @@ impl RenderTest for OpenGl4 { OpenGl4::new(path) } - fn render(&self, path: impl AsRef, frame_count: usize) -> anyhow::Result { + fn render(&mut self, path: impl AsRef, frame_count: usize) -> anyhow::Result { let mut filter_chain = unsafe { FilterChain::load_from_path( path, diff --git a/librashader-test/src/render/mod.rs b/librashader-test/src/render/mod.rs index a6fc298..395c8ef 100644 --- a/librashader-test/src/render/mod.rs +++ b/librashader-test/src/render/mod.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "d3d11")] +#[cfg(all(windows, feature = "d3d11"))] pub mod d3d11; -#[cfg(feature = "d3d12")] +#[cfg(all(windows, feature = "d3d12"))] pub mod d3d12; -#[cfg(feature = "d3d9")] +#[cfg(all(windows, feature = "d3d9"))] pub mod d3d9; #[cfg(feature = "opengl")] @@ -16,7 +16,7 @@ pub mod vk; #[cfg(feature = "wgpu")] pub mod wgpu; -#[cfg(feature = "metal")] +#[cfg(all(target_vendor = "apple", feature = "metal"))] pub mod mtl; use std::path::Path; @@ -66,7 +66,7 @@ mod test { } #[test] - #[cfg(feature = "d3d11")] + #[cfg(all(windows, feature = "d3d11"))] pub fn test_d3d11() -> anyhow::Result<()> { do_test::() } @@ -96,19 +96,19 @@ mod test { } #[test] - #[cfg(feature = "metal")] + #[cfg(all(target_vendor = "apple", feature = "metal"))] pub fn test_metal() -> anyhow::Result<()> { do_test::() } #[test] - #[cfg(feature = "d3d9")] + #[cfg(all(windows, feature = "d3d9"))] pub fn test_d3d9() -> anyhow::Result<()> { do_test::() } #[test] - #[cfg(feature = "d3d12")] + #[cfg(all(windows, feature = "d3d12"))] pub fn test_d3d12() -> anyhow::Result<()> { do_test::() } diff --git a/librashader-test/src/render/mtl.rs b/librashader-test/src/render/mtl.rs index f32fcd3..6ed172e 100644 --- a/librashader-test/src/render/mtl.rs +++ b/librashader-test/src/render/mtl.rs @@ -29,7 +29,7 @@ impl RenderTest for Metal { Metal::new(path) } - fn render(&self, path: impl AsRef, frame_count: usize) -> anyhow::Result { + fn render(&mut self, path: impl AsRef, frame_count: usize) -> anyhow::Result { let queue = self .device .newCommandQueue() diff --git a/librashader-test/src/render/vk/base.rs b/librashader-test/src/render/vk/base.rs index 4d88742..fbac283 100644 --- a/librashader-test/src/render/vk/base.rs +++ b/librashader-test/src/render/vk/base.rs @@ -1,7 +1,4 @@ -use crate::render::vk::physical_device::QueueFamilyIndices; -use ash::prelude::VkResult; use ash::vk; -use ash::vk::CommandBufferResetFlags; use gpu_allocator::vulkan::Allocator; use librashader::runtime::vk::VulkanObjects; use parking_lot::Mutex; diff --git a/librashader-test/src/render/vk/mod.rs b/librashader-test/src/render/vk/mod.rs index d17b2b3..99c66b2 100644 --- a/librashader-test/src/render/vk/mod.rs +++ b/librashader-test/src/render/vk/mod.rs @@ -8,7 +8,7 @@ use image::RgbaImage; use librashader::runtime::vk::{FilterChain, FilterChainOptions, VulkanImage}; use librashader::runtime::Viewport; use librashader_runtime::image::{Image, UVDirection, BGRA8}; -use std::io::{Cursor, Write}; +use std::io::Write; use std::path::Path; mod base; @@ -32,7 +32,7 @@ impl RenderTest for Vulkan { Vulkan::new(path) } - fn render(&self, path: impl AsRef, frame_count: usize) -> anyhow::Result { + fn render(&mut self, path: impl AsRef, frame_count: usize) -> anyhow::Result { unsafe { let mut filter_chain = FilterChain::load_from_path( path, diff --git a/librashader-test/src/render/vk/util.rs b/librashader-test/src/render/vk/util.rs index 8c8c1d3..738d5b0 100644 --- a/librashader-test/src/render/vk/util.rs +++ b/librashader-test/src/render/vk/util.rs @@ -1,9 +1,4 @@ use ash::vk; -use gpu_allocator::vulkan::{Allocator, AllocatorCreateDesc}; - -use gpu_allocator::AllocationSizes; -use parking_lot::Mutex; -use std::sync::Arc; #[inline(always)] pub unsafe fn vulkan_image_layout_transition_levels( diff --git a/librashader-test/src/render/wgpu.rs b/librashader-test/src/render/wgpu.rs index ec1f6a8..c5787a5 100644 --- a/librashader-test/src/render/wgpu.rs +++ b/librashader-test/src/render/wgpu.rs @@ -5,7 +5,7 @@ use librashader::runtime::wgpu::*; use librashader::runtime::Viewport; use librashader_runtime::image::{Image, UVDirection}; use std::io::{Cursor, Write}; -use std::ops::{Deref, DerefMut}; +use std::ops::DerefMut; use std::path::Path; use std::sync::Arc; use wgpu::{Adapter, Device, Instance, Queue, Texture}; @@ -56,7 +56,7 @@ impl RenderTest for Wgpu { Wgpu::new(path) } - fn render(&self, path: impl AsRef, frame_count: usize) -> anyhow::Result { + fn render(&mut self, path: impl AsRef, frame_count: usize) -> anyhow::Result { let mut chain = FilterChain::load_from_path( path, Arc::clone(&self.device),