d3d11: passoutput
This commit is contained in:
parent
f2d67f9160
commit
c4f1abd411
5 changed files with 23 additions and 7 deletions
|
@ -52,6 +52,7 @@ pub struct FilterCommon {
|
|||
pub(crate) luts: FxHashMap<usize, OwnedTexture>,
|
||||
pub samplers: SamplerSet,
|
||||
pub(crate) draw_quad: DrawQuad,
|
||||
pub output_textures: Box<[Option<Texture>]>
|
||||
}
|
||||
|
||||
impl FilterChain {
|
||||
|
@ -196,8 +197,8 @@ impl FilterChain {
|
|||
let mut output_framebuffers = Vec::new();
|
||||
output_framebuffers.resize_with(filters.len(), || OwnedFramebuffer::new(device, Size::new(1, 1),
|
||||
ImageFormat::R8G8B8A8Unorm).unwrap());
|
||||
// let mut output_textures = Vec::new();
|
||||
// output_textures.resize_with(filters.len(), Texture::default);
|
||||
let mut output_textures = Vec::new();
|
||||
output_textures.resize_with(filters.len(), || None);
|
||||
//
|
||||
// // initialize feedback framebuffers
|
||||
// let mut feedback_framebuffers = Vec::new();
|
||||
|
@ -236,7 +237,7 @@ impl FilterChain {
|
|||
// we don't need the reflect semantics once all locations have been bound per pass.
|
||||
// semantics,
|
||||
preset,
|
||||
// output_textures: output_textures.into_boxed_slice(),
|
||||
output_textures: output_textures.into_boxed_slice(),
|
||||
// feedback_textures: feedback_textures.into_boxed_slice(),
|
||||
// history_textures,
|
||||
draw_quad,
|
||||
|
@ -376,6 +377,7 @@ impl FilterChain {
|
|||
filter,
|
||||
wrap_mode,
|
||||
};
|
||||
self.common.output_textures[index] = Some(source.clone());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -194,21 +194,23 @@ impl FilterPass {
|
|||
|
||||
// PassOutput
|
||||
for (index, output) in parent.output_textures.iter().enumerate() {
|
||||
let Some(output) = output else {
|
||||
continue;
|
||||
};
|
||||
if let Some(binding) = self
|
||||
.reflection
|
||||
.meta
|
||||
.texture_meta
|
||||
.get(&TextureSemantics::PassOutput.semantics(index))
|
||||
{
|
||||
FilterPass::bind_texture(binding, output);
|
||||
FilterPass::bind_texture(&parent.samplers, &mut textures, &mut samplers, binding, output);
|
||||
}
|
||||
|
||||
if let Some(offset) = self
|
||||
.uniform_bindings
|
||||
.get(&TextureSemantics::PassOutput.semantics(index).into())
|
||||
{
|
||||
self.uniform_storage.bind_vec4(*offset, output.image.size, None);
|
||||
|
||||
self.uniform_storage.bind_vec4(*offset, output.view.size, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ impl OwnedFramebuffer {
|
|||
let format = d3d11_get_closest_format(&self.device, DXGI_FORMAT::from(format),
|
||||
D3D11_FORMAT_SUPPORT_TEXTURE2D.0 |
|
||||
D3D11_FORMAT_SUPPORT_SHADER_SAMPLE.0 | D3D11_FORMAT_SUPPORT_RENDER_TARGET.0);
|
||||
|
||||
let desc = default_desc(size, format);
|
||||
unsafe {
|
||||
let mut texture = self.device.CreateTexture2D(&desc, None)?;
|
||||
|
|
|
@ -34,7 +34,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn triangle_d3d11() {
|
||||
let sample = hello_triangle::d3d11_hello_triangle::Sample::new("../test/basic.slangp").unwrap();
|
||||
let sample = hello_triangle::d3d11_hello_triangle::Sample::new("../test/slang-shaders/crt/crt-royale.slangp").unwrap();
|
||||
// let sample = hello_triangle::d3d11_hello_triangle::Sample::new("../test/basic.slangp").unwrap();
|
||||
|
||||
hello_triangle::main(sample).unwrap();
|
||||
|
|
|
@ -165,3 +165,14 @@ pub fn d3d11_create_input_layout(device: &ID3D11Device, desc: &[D3D11_INPUT_ELEM
|
|||
|
||||
// todo: d3d11.c 2097
|
||||
pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
|
||||
|
||||
pub fn calc_miplevel(size: Size<u32>) -> u32 {
|
||||
let mut size = std::cmp::max(size.width, size.height);
|
||||
let mut levels = 0;
|
||||
while size != 0 {
|
||||
levels += 1;
|
||||
size >>= 1;
|
||||
}
|
||||
|
||||
levels
|
||||
}
|
Loading…
Add table
Reference in a new issue