rt(d3d12): get rid of size in inputview

This commit is contained in:
chyyran 2024-03-07 20:56:30 -05:00 committed by Ronny Chan
parent 4d6793d305
commit 3cda5b706d
5 changed files with 24 additions and 16 deletions

View file

@ -26,11 +26,11 @@ pub struct libra_source_image_d3d12_t {
pub resource: ManuallyDrop<ID3D12Resource>, pub resource: ManuallyDrop<ID3D12Resource>,
/// A CPU descriptor handle to a shader resource view of the image. /// A CPU descriptor handle to a shader resource view of the image.
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE, pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
/// The format of the image. /// This is currently ignored.
pub format: DXGI_FORMAT, pub format: DXGI_FORMAT,
/// The width of the source image. /// This is currently ignored.
pub width: u32, pub width: u32,
/// The height of the source image. /// This is currently ignored.
pub height: u32, pub height: u32,
} }
@ -104,8 +104,6 @@ impl TryFrom<libra_source_image_d3d12_t> for D3D12InputImage {
Ok(D3D12InputImage { Ok(D3D12InputImage {
resource: ManuallyDrop::into_inner(resource), resource: ManuallyDrop::into_inner(resource),
descriptor: value.descriptor, descriptor: value.descriptor,
size: Size::new(value.width, value.height),
format: value.format,
}) })
} }
} }

View file

@ -8,8 +8,6 @@ use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT;
pub struct D3D12InputImage { pub struct D3D12InputImage {
pub resource: ID3D12Resource, pub resource: ID3D12Resource,
pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE, pub descriptor: D3D12_CPU_DESCRIPTOR_HANDLE,
pub size: Size<u32>,
pub format: DXGI_FORMAT,
} }
#[derive(Clone)] #[derive(Clone)]
@ -117,11 +115,12 @@ impl InputTexture {
filter: FilterMode, filter: FilterMode,
wrap_mode: WrapMode, wrap_mode: WrapMode,
) -> InputTexture { ) -> InputTexture {
let desc = unsafe { image.resource.GetDesc() };
InputTexture { InputTexture {
resource: image.resource, resource: image.resource,
descriptor: InputDescriptor::Raw(image.descriptor), descriptor: InputDescriptor::Raw(image.descriptor),
size: image.size, size: Size::new(desc.Width as u32, desc.Height),
format: image.format, format: desc.Format,
wrap_mode, wrap_mode,
filter, filter,
} }

View file

@ -21,6 +21,7 @@ use windows::Win32::Graphics::Direct3D12::{
D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX,
}; };
use windows::Win32::Graphics::Dxgi::Common::*; use windows::Win32::Graphics::Dxgi::Common::*;
use librashader_common::Size;
/// wtf retroarch? /// wtf retroarch?
const DXGI_FORMAT_EX_A4R4G4B4_UNORM: DXGI_FORMAT = DXGI_FORMAT(1000); const DXGI_FORMAT_EX_A4R4G4B4_UNORM: DXGI_FORMAT = DXGI_FORMAT(1000);
@ -387,3 +388,18 @@ unsafe fn memcpy_subresource(
} }
} }
} }
pub(crate) trait GetSize {
fn size(&self) -> Size<u32>;
}
impl GetSize for ID3D12Resource {
fn size(&self) -> Size<u32> {
let desc = unsafe {
self.GetDesc()
};
Size::new(desc.Width as u32, desc.Height)
}
}

View file

@ -624,11 +624,6 @@ pub mod d3d12_hello_triangle {
D3D12InputImage { D3D12InputImage {
resource: resources.framebuffer.clone(), resource: resources.framebuffer.clone(),
descriptor: framebuffer, descriptor: framebuffer,
size: Size::new(
resources.viewport.Width as u32,
resources.viewport.Height as u32,
),
format: DXGI_FORMAT_R8G8B8A8_UNORM,
}, },
&Viewport { &Viewport {
x: 0.0, x: 0.0,

View file

@ -6,12 +6,12 @@ use crate::hello_triangle::{DXSample, SampleCommandLine};
fn triangle_d3d12() { fn triangle_d3d12() {
let sample = hello_triangle::d3d12_hello_triangle::Sample::new( let sample = hello_triangle::d3d12_hello_triangle::Sample::new(
// "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp", // "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// "../test/shaders_slang/crt/crt-lottes.slangp", "../test/shaders_slang/crt/crt-lottes.slangp",
// "../test/basic.slangp", // "../test/basic.slangp",
// "../test/shaders_slang/handheld/console-border/gbc-lcd-grid-v2.slangp", // "../test/shaders_slang/handheld/console-border/gbc-lcd-grid-v2.slangp",
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp", // "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp",
// "../test/slang-shaders/test/feedback.slangp", // "../test/slang-shaders/test/feedback.slangp",
"../test/shaders_slang/test/history.slangp", // "../test/shaders_slang/test/history.slangp",
// "../test/shaders_slang/crt/crt-royale.slangp", // "../test/shaders_slang/crt/crt-royale.slangp",
// "../test/slang-shaders/vhs/VHSPro.slangp", // "../test/slang-shaders/vhs/VHSPro.slangp",
&SampleCommandLine { &SampleCommandLine {