fmt: clean up warnings
This commit is contained in:
parent
55e800b67e
commit
121209da10
|
@ -106,7 +106,9 @@ Please report an issue if you run into a shader that works in RetroArch, but not
|
|||
* Shaders are compiled in parallel where possible. This should noticeably decrease preset compile times.
|
||||
Parallel shader compilation is not available to OpenGL.
|
||||
* HDR10 support is not part of any shader runtime and is not supported by librashader.
|
||||
|
||||
* For performance reasons, mipmaps are never generated for the input texture. In theory, this means that
|
||||
presets with `mipmap_input0 = "true"` will not get a mipmapped input. In practice, no known shader presets set
|
||||
`mipmap_input0 = "true"`.
|
||||
### Runtime specific differences
|
||||
* OpenGL
|
||||
* Copying of in-flight framebuffer contents to history is done via `glBlitFramebuffer` rather than drawing a quad into an intermediate FBO.
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::error::{assume_d3d11_init, FilterChainError};
|
|||
use crate::texture::D3D11InputView;
|
||||
use crate::util::d3d11_get_closest_format;
|
||||
use crate::{error, D3D11OutputView};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_presets::Scale2D;
|
||||
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
|
||||
use windows::core::Interface;
|
||||
|
@ -14,7 +14,7 @@ use windows::Win32::Graphics::Direct3D11::{
|
|||
D3D11_FORMAT_SUPPORT_TEXTURE2D, D3D11_RENDER_TARGET_VIEW_DESC, D3D11_RENDER_TARGET_VIEW_DESC_0,
|
||||
D3D11_RESOURCE_MISC_GENERATE_MIPS, D3D11_RTV_DIMENSION_TEXTURE2D,
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC, D3D11_SHADER_RESOURCE_VIEW_DESC_0, D3D11_TEX2D_RTV,
|
||||
D3D11_TEX2D_SRV, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_VIEWPORT,
|
||||
D3D11_TEX2D_SRV, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT,
|
||||
};
|
||||
use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT, DXGI_SAMPLE_DESC};
|
||||
|
||||
|
@ -227,20 +227,6 @@ impl OwnedFramebuffer {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct OutputFramebuffer {
|
||||
pub rtv: ID3D11RenderTargetView,
|
||||
pub size: Size<u32>,
|
||||
}
|
||||
|
||||
impl<'a> From<&Viewport<'a, D3D11OutputView>> for OutputFramebuffer {
|
||||
fn from(value: &Viewport<'a, D3D11OutputView>) -> Self {
|
||||
OutputFramebuffer {
|
||||
rtv: value.output.handle.clone(),
|
||||
size: value.output.size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_desc(size: Size<u32>, format: DXGI_FORMAT, mip_levels: u32) -> D3D11_TEXTURE2D_DESC {
|
||||
D3D11_TEXTURE2D_DESC {
|
||||
|
@ -259,16 +245,6 @@ fn default_desc(size: Size<u32>, format: DXGI_FORMAT, mip_levels: u32) -> D3D11_
|
|||
MiscFlags: D3D11_RESOURCE_MISC_GENERATE_MIPS,
|
||||
}
|
||||
}
|
||||
pub const fn default_viewport(size: Size<u32>) -> D3D11_VIEWPORT {
|
||||
D3D11_VIEWPORT {
|
||||
TopLeftX: 0.0,
|
||||
TopLeftY: 0.0,
|
||||
Width: size.width as f32,
|
||||
Height: size.height as f32,
|
||||
MinDepth: 0.0,
|
||||
MaxDepth: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
impl ScaleFramebuffer for OwnedFramebuffer {
|
||||
type Error = FilterChainError;
|
||||
|
|
|
@ -19,7 +19,7 @@ pub struct D3D11StateSaveGuard<'a> {
|
|||
saved_blend_factor: [f32; 4],
|
||||
saved_blend_mask: u32,
|
||||
saved_rs: Option<ID3D11RasterizerState>,
|
||||
state: &'a D3D11State,
|
||||
_state: &'a D3D11State,
|
||||
}
|
||||
|
||||
impl D3D11State {
|
||||
|
@ -95,7 +95,7 @@ impl D3D11State {
|
|||
saved_blend_factor,
|
||||
saved_blend_mask,
|
||||
saved_rs,
|
||||
state: self,
|
||||
_state: self,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -84,11 +84,11 @@ pub trait DXSample {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn LOWORD(l: usize) -> u32 {
|
||||
pub fn loword(l: usize) -> u32 {
|
||||
(l & 0xffff) as u32
|
||||
}
|
||||
#[inline]
|
||||
pub fn HIWORD(l: usize) -> u32 {
|
||||
pub fn hiword(l: usize) -> u32 {
|
||||
((l >> 16) & 0xffff) as u32
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ fn sample_wndproc<S: DXSample>(sample: &mut S, message: u32, wparam: WPARAM) ->
|
|||
true
|
||||
}
|
||||
WM_SIZE => {
|
||||
sample.resize(LOWORD(wparam.0), HIWORD(wparam.0)).unwrap();
|
||||
sample.resize(loword(wparam.0), hiword(wparam.0)).unwrap();
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
|
|
|
@ -84,7 +84,7 @@ mod tests {
|
|||
FILTER_PATH,
|
||||
Some(&FilterChainOptionsD3D11 {
|
||||
use_deferred_context: false,
|
||||
force_no_mipmaps: true,
|
||||
force_no_mipmaps: false,
|
||||
}),
|
||||
// replace below with 'None' for the triangle
|
||||
// None,
|
||||
|
|
|
@ -47,7 +47,7 @@ use windows::Win32::System::Threading::{CreateEventA, ResetEvent, WaitForSingleO
|
|||
use windows::Win32::System::WindowsProgramming::INFINITE;
|
||||
|
||||
use librashader_runtime::render_target::RenderTarget;
|
||||
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer};
|
||||
use librashader_runtime::scaling::ScaleFramebuffer;
|
||||
use rayon::prelude::*;
|
||||
|
||||
const MIPMAP_RESERVED_WORKHEAP_DESCRIPTORS: usize = 1024;
|
||||
|
@ -310,7 +310,7 @@ impl FilterChainD3D12 {
|
|||
NodeMask: 0,
|
||||
})?;
|
||||
|
||||
let fence_event = unsafe { CreateEventA(None, false, false, None)? };
|
||||
let fence_event = CreateEventA(None, false, false, None)?;
|
||||
let fence: ID3D12Fence = device.CreateFence(0, D3D12_FENCE_FLAG_NONE)?;
|
||||
let mut residuals = Vec::new();
|
||||
|
||||
|
@ -338,11 +338,10 @@ impl FilterChainD3D12 {
|
|||
queue.Signal(&fence, 1)?;
|
||||
|
||||
// Wait until finished
|
||||
if unsafe { fence.GetCompletedValue() } < 1 {
|
||||
unsafe { fence.SetEventOnCompletion(1, fence_event)? };
|
||||
|
||||
unsafe { WaitForSingleObject(fence_event, INFINITE) };
|
||||
unsafe { ResetEvent(fence_event) };
|
||||
if fence.GetCompletedValue() < 1 {
|
||||
fence.SetEventOnCompletion(1, fence_event)?;
|
||||
WaitForSingleObject(fence_event, INFINITE);
|
||||
ResetEvent(fence_event);
|
||||
}
|
||||
|
||||
cmd.Reset(&command_pool, None)?;
|
||||
|
@ -360,11 +359,10 @@ impl FilterChainD3D12 {
|
|||
queue.ExecuteCommandLists(&[cmd.cast()?]);
|
||||
queue.Signal(&fence, 2)?;
|
||||
//
|
||||
if unsafe { fence.GetCompletedValue() } < 2 {
|
||||
unsafe { fence.SetEventOnCompletion(2, fence_event)? }
|
||||
|
||||
unsafe { WaitForSingleObject(fence_event, INFINITE) };
|
||||
unsafe { CloseHandle(fence_event) };
|
||||
if fence.GetCompletedValue() < 2 {
|
||||
fence.SetEventOnCompletion(2, fence_event)?;
|
||||
WaitForSingleObject(fence_event, INFINITE);
|
||||
CloseHandle(fence_event);
|
||||
}
|
||||
|
||||
drop(residuals);
|
||||
|
@ -701,8 +699,7 @@ impl FilterChainD3D12 {
|
|||
);
|
||||
|
||||
if target.max_mipmap > 1 && !self.disable_mipmaps {
|
||||
let residuals = unsafe {
|
||||
self.common.mipmap_gen.mipmapping_context(
|
||||
let residuals = self.common.mipmap_gen.mipmapping_context(
|
||||
cmd,
|
||||
&mut self.mipmap_heap,
|
||||
|ctx| {
|
||||
|
@ -714,8 +711,7 @@ impl FilterChainD3D12 {
|
|||
)?;
|
||||
Ok::<(), FilterChainError>(())
|
||||
},
|
||||
)?
|
||||
};
|
||||
)?;
|
||||
|
||||
self.residuals.dispose_mipmap_handles(residuals);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ impl OwnedImage {
|
|||
format: ImageFormat,
|
||||
mipmap: bool,
|
||||
) -> error::Result<OwnedImage> {
|
||||
unsafe {
|
||||
let miplevels = if mipmap {
|
||||
size.calculate_miplevels()
|
||||
} else {
|
||||
|
@ -107,7 +106,6 @@ impl OwnedImage {
|
|||
max_mipmap: miplevels as u16,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// SAFETY: self must fit the source image
|
||||
/// source must be in D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE
|
||||
|
|
|
@ -307,13 +307,8 @@ impl D3D12GraphicsPipeline {
|
|||
root_signature: &D3D12RootSignature,
|
||||
render_format: DXGI_FORMAT,
|
||||
) -> error::Result<D3D12GraphicsPipeline> {
|
||||
unsafe {
|
||||
let vertex_dxil = util::dxc_compile_shader(
|
||||
library,
|
||||
dxc,
|
||||
&shader_assembly.vertex,
|
||||
BindingStage::VERTEX,
|
||||
)?;
|
||||
let vertex_dxil =
|
||||
util::dxc_compile_shader(library, dxc, &shader_assembly.vertex, BindingStage::VERTEX)?;
|
||||
let fragment_dxil = util::dxc_compile_shader(
|
||||
library,
|
||||
dxc,
|
||||
|
@ -329,5 +324,4 @@ impl D3D12GraphicsPipeline {
|
|||
render_format,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#![cfg(test)]
|
||||
use std::ffi::CStr;
|
||||
use windows::{
|
||||
core::*, Win32::Foundation::*, Win32::Graphics::Direct3D::Fxc::*, Win32::Graphics::Direct3D::*,
|
||||
|
@ -56,18 +57,6 @@ pub struct SampleCommandLine {
|
|||
pub use_warp_device: bool,
|
||||
}
|
||||
|
||||
fn build_command_line() -> SampleCommandLine {
|
||||
let mut use_warp_device = false;
|
||||
|
||||
for arg in std::env::args() {
|
||||
if arg.eq_ignore_ascii_case("-warp") || arg.eq_ignore_ascii_case("/warp") {
|
||||
use_warp_device = true;
|
||||
}
|
||||
}
|
||||
|
||||
SampleCommandLine { use_warp_device }
|
||||
}
|
||||
|
||||
fn run_sample<S>(mut sample: S) -> Result<()>
|
||||
where
|
||||
S: DXSample,
|
||||
|
@ -938,7 +927,7 @@ pub mod d3d12_hello_triangle {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main<S: DXSample>(sample: S) -> Result<()> {
|
||||
pub(crate) fn main<S: DXSample>(sample: S) -> Result<()> {
|
||||
run_sample(sample)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -156,7 +156,6 @@ impl LutTexture {
|
|||
}
|
||||
assume_d3d12_init!(upload, "CreateCommittedResource");
|
||||
|
||||
unsafe {
|
||||
let subresource = [D3D12_SUBRESOURCE_DATA {
|
||||
pData: source.bytes.as_ptr().cast(),
|
||||
RowPitch: 4 * source.size.width as isize,
|
||||
|
@ -177,8 +176,7 @@ impl LutTexture {
|
|||
&resource,
|
||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
let view = InputTexture::new(
|
||||
resource.clone(),
|
||||
|
|
|
@ -67,7 +67,6 @@ pub struct D3D12MipmapGen {
|
|||
root_signature: ID3D12RootSignature,
|
||||
pipeline: ID3D12PipelineState,
|
||||
own_heaps: bool,
|
||||
root_index_offset: usize,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Zeroable, Pod)]
|
||||
|
@ -147,7 +146,6 @@ impl D3D12MipmapGen {
|
|||
root_signature,
|
||||
pipeline,
|
||||
own_heaps,
|
||||
root_index_offset: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +167,10 @@ impl D3D12MipmapGen {
|
|||
///
|
||||
/// If own_heap is false, then you must ensure that the compute root signature
|
||||
/// is already bound before entering the context.
|
||||
///
|
||||
/// The list of returned descriptors must be kept around until the command list has been
|
||||
/// submitted.
|
||||
#[must_use]
|
||||
pub fn mipmapping_context<F, E>(
|
||||
&self,
|
||||
cmd: &ID3D12GraphicsCommandList,
|
||||
|
|
|
@ -70,7 +70,7 @@ const FINAL_VBO_DATA: [D3D12Vertex; 4] = [
|
|||
static VBO_DATA: &[D3D12Vertex; 8] = &concat_arrays!(OFFSCREEN_VBO_DATA, FINAL_VBO_DATA);
|
||||
|
||||
pub(crate) struct DrawQuad {
|
||||
buffer: ID3D12Resource,
|
||||
_buffer: ID3D12Resource,
|
||||
view: D3D12_VERTEX_BUFFER_VIEW,
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,10 @@ impl DrawQuad {
|
|||
};
|
||||
|
||||
let buffer = buffer.into_raw();
|
||||
Ok(DrawQuad { buffer, view })
|
||||
Ok(DrawQuad {
|
||||
_buffer: buffer,
|
||||
view,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn bind_vertices_for_frame(&self, cmd: &ID3D12GraphicsCommandList) {
|
||||
|
|
|
@ -10,7 +10,7 @@ use windows::Win32::Graphics::Direct3D12::{
|
|||
|
||||
pub struct SamplerSet {
|
||||
samplers: FxHashMap<(WrapMode, FilterMode), D3D12DescriptorHeapSlot<SamplerPaletteHeap>>,
|
||||
heap: D3D12DescriptorHeap<SamplerPaletteHeap>,
|
||||
_heap: D3D12DescriptorHeap<SamplerPaletteHeap>,
|
||||
}
|
||||
|
||||
impl SamplerSet {
|
||||
|
@ -73,6 +73,9 @@ impl SamplerSet {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(SamplerSet { samplers, heap })
|
||||
Ok(SamplerSet {
|
||||
samplers,
|
||||
_heap: heap,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,8 +287,8 @@ pub fn d3d12_update_subresources(
|
|||
let mut num_rows = vec![0; num_subresources as usize];
|
||||
let mut row_sizes_in_bytes = vec![0; num_subresources as usize];
|
||||
let mut required_size = 0;
|
||||
|
||||
// texture upload
|
||||
unsafe {
|
||||
device.GetCopyableFootprints(
|
||||
&destination_desc,
|
||||
first_subresouce,
|
||||
|
@ -299,7 +299,6 @@ pub fn d3d12_update_subresources(
|
|||
Some(row_sizes_in_bytes.as_mut_ptr()),
|
||||
Some(&mut required_size),
|
||||
);
|
||||
}
|
||||
|
||||
update_subresources(
|
||||
cmd,
|
||||
|
|
|
@ -5,8 +5,8 @@ use ash::vk;
|
|||
use std::sync::Arc;
|
||||
|
||||
pub struct VulkanCommandPool {
|
||||
pool: vk::CommandPool,
|
||||
device: Arc<ash::Device>,
|
||||
_pool: vk::CommandPool,
|
||||
_device: Arc<ash::Device>,
|
||||
pub buffers: Vec<vk::CommandBuffer>,
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,8 @@ impl VulkanCommandPool {
|
|||
|
||||
let buffers = base.device.allocate_command_buffers(&buffer_info)?;
|
||||
Ok(VulkanCommandPool {
|
||||
pool,
|
||||
device: base.device.clone(),
|
||||
_pool: pool,
|
||||
_device: base.device.clone(),
|
||||
buffers,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ pub struct VulkanDebug {
|
|||
messenger: DebugUtilsMessengerEXT,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl VulkanDebug {
|
||||
pub fn new(
|
||||
entry: &ash::Entry,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![cfg(test)]
|
||||
#![allow(unused_variables)]
|
||||
mod command;
|
||||
mod debug;
|
||||
mod framebuffer;
|
||||
|
@ -6,7 +8,7 @@ mod pipeline;
|
|||
mod surface;
|
||||
mod swapchain;
|
||||
mod syncobjects;
|
||||
pub mod vulkan_base;
|
||||
pub(crate) mod vulkan_base;
|
||||
|
||||
use crate::filter_chain::FilterChainVulkan;
|
||||
use crate::hello_triangle::command::VulkanCommandPool;
|
||||
|
@ -391,7 +393,7 @@ pub fn find_memorytype_index(
|
|||
}
|
||||
|
||||
pub struct VulkanDraw {
|
||||
surface: VulkanSurface,
|
||||
_surface: VulkanSurface,
|
||||
base: VulkanBase,
|
||||
pub swapchain: VulkanSwapchain,
|
||||
pub pipeline: VulkanPipeline,
|
||||
|
@ -435,7 +437,7 @@ pub fn main(vulkan: VulkanBase, filter_chain: FilterChainVulkan) {
|
|||
let sync = SyncObjects::new(&vulkan.device, MAX_FRAMES_IN_FLIGHT).unwrap();
|
||||
|
||||
let vulkan = VulkanDraw {
|
||||
surface,
|
||||
_surface: surface,
|
||||
swapchain,
|
||||
base: vulkan,
|
||||
pipeline,
|
||||
|
|
|
@ -12,7 +12,7 @@ pub struct VulkanSwapchain {
|
|||
pub loader: ash::extensions::khr::Swapchain,
|
||||
pub format: vk::SurfaceFormatKHR,
|
||||
pub extent: vk::Extent2D,
|
||||
mode: vk::PresentModeKHR,
|
||||
pub mode: vk::PresentModeKHR,
|
||||
pub swapchain_images: Vec<vk::Image>,
|
||||
pub swapchain_image_views: Vec<vk::ImageView>,
|
||||
|
||||
|
@ -92,7 +92,7 @@ impl VulkanSwapchain {
|
|||
|
||||
unsafe {
|
||||
let image = base.device.create_image(&create_info, None)?;
|
||||
let mem_reqs = unsafe { base.device.get_image_memory_requirements(image) };
|
||||
let mem_reqs = base.device.get_image_memory_requirements(image);
|
||||
|
||||
let memory =
|
||||
VulkanImageMemory::new(&base.device, &base.allocator, mem_reqs, &image)
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::hello_triangle::physicaldevice::{find_queue_family, pick_physical_dev
|
|||
|
||||
use crate::util;
|
||||
use ash::prelude::VkResult;
|
||||
use gpu_allocator::vulkan::{Allocator, AllocatorCreateDesc};
|
||||
use gpu_allocator::vulkan::Allocator;
|
||||
use parking_lot::RwLock;
|
||||
use std::ffi::CStr;
|
||||
use std::sync::Arc;
|
||||
|
@ -44,7 +44,7 @@ impl VulkanBase {
|
|||
ash::extensions::ext::DebugUtils::name().as_ptr(),
|
||||
];
|
||||
|
||||
let layers = unsafe { [KHRONOS_VALIDATION.as_ptr().cast()] };
|
||||
let layers = [KHRONOS_VALIDATION.as_ptr().cast()];
|
||||
|
||||
let create_info = vk::InstanceCreateInfo::builder()
|
||||
.application_info(&app_info)
|
||||
|
@ -125,6 +125,7 @@ impl VulkanBase {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
unsafe extern "system" fn vulkan_debug_callback(
|
||||
_message_severity: vk::DebugUtilsMessageSeverityFlagsEXT,
|
||||
_message_type: vk::DebugUtilsMessageTypeFlagsEXT,
|
||||
|
|
|
@ -15,7 +15,6 @@ use std::sync::Arc;
|
|||
pub struct VulkanImageMemory {
|
||||
allocation: Option<Allocation>,
|
||||
allocator: Arc<RwLock<Allocator>>,
|
||||
device: Arc<ash::Device>,
|
||||
}
|
||||
|
||||
impl VulkanImageMemory {
|
||||
|
@ -38,7 +37,6 @@ impl VulkanImageMemory {
|
|||
Ok(VulkanImageMemory {
|
||||
allocation: Some(allocation),
|
||||
allocator: Arc::clone(allocator),
|
||||
device: Arc::clone(device),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +44,6 @@ impl VulkanImageMemory {
|
|||
|
||||
impl Drop for VulkanImageMemory {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let allocation = self.allocation.take();
|
||||
if let Some(allocation) = allocation {
|
||||
if let Err(e) = self.allocator.write().free(allocation) {
|
||||
|
@ -54,7 +51,6 @@ impl Drop for VulkanImageMemory {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VulkanBuffer {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ash::vk;
|
||||
use gpu_allocator::vulkan::{Allocator, AllocatorCreateDesc};
|
||||
use gpu_allocator::AllocatorDebugSettings;
|
||||
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
Loading…
Reference in a new issue