feat: cubic filtering
This commit is contained in:
@@ -6,7 +6,7 @@ use openxr as xr;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use vulkano::{
|
||||
image::{sampler::Filter, sys::RawImage, view::ImageView, ImageCreateInfo, ImageUsage},
|
||||
image::{sys::RawImage, view::ImageView, ImageCreateInfo, ImageUsage},
|
||||
pipeline::graphics::color_blend::AttachmentBlend,
|
||||
Handle,
|
||||
};
|
||||
@@ -96,9 +96,11 @@ impl SwapchainRenderData {
|
||||
|
||||
let target_extent = render_target.image().extent();
|
||||
|
||||
let set0 = self
|
||||
.pipeline
|
||||
.uniform_sampler(0, view.clone(), Filter::Linear)?;
|
||||
let set0 = self.pipeline.uniform_sampler(
|
||||
0,
|
||||
view.clone(),
|
||||
command_buffer.graphics.texture_filtering,
|
||||
)?;
|
||||
|
||||
let set1 = self.pipeline.uniform_buffer(1, vec![alpha])?;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ impl PreviewState {
|
||||
)
|
||||
}?;
|
||||
let set0 = pipeline
|
||||
.uniform_sampler(0, view.clone(), Filter::Linear)
|
||||
.uniform_sampler(0, view.clone(), pipeline.graphics.texture_filtering)
|
||||
.unwrap();
|
||||
|
||||
let pass = pipeline
|
||||
|
||||
@@ -124,6 +124,7 @@ pub struct WlxGraphics {
|
||||
pub queue: Arc<Queue>,
|
||||
|
||||
pub native_format: Format,
|
||||
pub texture_filtering: Filter,
|
||||
|
||||
pub memory_allocator: Arc<StandardMemoryAllocator>,
|
||||
pub command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
|
||||
@@ -267,6 +268,10 @@ impl WlxGraphics {
|
||||
.ext_image_drm_format_modifier;
|
||||
}
|
||||
|
||||
if physical_device.supported_extensions().ext_filter_cubic {
|
||||
device_extensions.ext_filter_cubic = true;
|
||||
}
|
||||
|
||||
let device_extensions_raw = device_extensions
|
||||
.into_iter()
|
||||
.filter_map(|(name, enabled)| {
|
||||
@@ -300,6 +305,12 @@ impl WlxGraphics {
|
||||
dynamic_rendering.p_next = device_create_info.p_next as _;
|
||||
device_create_info.p_next = (&mut dynamic_rendering) as *const _ as *const c_void;
|
||||
|
||||
let texture_filtering = if physical_device.supported_extensions().ext_filter_cubic {
|
||||
Filter::Cubic
|
||||
} else {
|
||||
Filter::Linear
|
||||
};
|
||||
|
||||
let (device, mut queues) = unsafe {
|
||||
let vk_device = xr_instance
|
||||
.create_vulkan_device(
|
||||
@@ -368,6 +379,7 @@ impl WlxGraphics {
|
||||
device,
|
||||
queue,
|
||||
native_format: Format::R8G8B8A8_UNORM,
|
||||
texture_filtering,
|
||||
memory_allocator,
|
||||
command_buffer_allocator,
|
||||
descriptor_set_allocator,
|
||||
@@ -430,6 +442,10 @@ impl WlxGraphics {
|
||||
p.supported_extensions().ext_image_drm_format_modifier;
|
||||
}
|
||||
|
||||
if p.supported_extensions().ext_filter_cubic {
|
||||
my_extensions.ext_filter_cubic = true;
|
||||
}
|
||||
|
||||
log::debug!(
|
||||
"Device exts for {}: {:?}",
|
||||
p.properties().device_name,
|
||||
@@ -459,6 +475,12 @@ impl WlxGraphics {
|
||||
physical_device.properties().device_name,
|
||||
);
|
||||
|
||||
let texture_filtering = if physical_device.supported_extensions().ext_filter_cubic {
|
||||
Filter::Cubic
|
||||
} else {
|
||||
Filter::Linear
|
||||
};
|
||||
|
||||
let (device, mut queues) = Device::new(
|
||||
physical_device,
|
||||
DeviceCreateInfo {
|
||||
@@ -509,6 +531,7 @@ impl WlxGraphics {
|
||||
queue,
|
||||
memory_allocator,
|
||||
native_format: Format::R8G8B8A8_UNORM,
|
||||
texture_filtering,
|
||||
command_buffer_allocator,
|
||||
descriptor_set_allocator,
|
||||
quad_indices,
|
||||
@@ -644,6 +667,7 @@ impl WlxGraphics {
|
||||
queue,
|
||||
memory_allocator,
|
||||
native_format,
|
||||
texture_filtering: Filter::Linear,
|
||||
command_buffer_allocator,
|
||||
descriptor_set_allocator,
|
||||
quad_indices,
|
||||
|
||||
@@ -5,7 +5,7 @@ use glam::{Vec2, Vec4};
|
||||
use vulkano::{
|
||||
command_buffer::CommandBufferUsage,
|
||||
format::Format,
|
||||
image::{sampler::Filter, view::ImageView, ImageLayout},
|
||||
image::{view::ImageView, ImageLayout},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -353,8 +353,10 @@ impl<D, S> Canvas<D, S> {
|
||||
ImageLayout::TransferSrcOptimal,
|
||||
)?;
|
||||
|
||||
let set_fg = pipeline_final.uniform_sampler(0, view_fg.clone(), Filter::Linear)?;
|
||||
let set_bg = pipeline_final.uniform_sampler(0, view_bg.clone(), Filter::Linear)?;
|
||||
let set_fg =
|
||||
pipeline_final.uniform_sampler(0, view_fg.clone(), graphics.texture_filtering)?;
|
||||
let set_bg =
|
||||
pipeline_final.uniform_sampler(0, view_bg.clone(), graphics.texture_filtering)?;
|
||||
let pass_fg = pipeline_final.create_pass(
|
||||
[width as _, height as _],
|
||||
vertex_buffer.clone(),
|
||||
@@ -761,7 +763,7 @@ impl<D, S> Control<D, S> {
|
||||
let set0 = canvas.pipeline_fg_glyph.uniform_sampler(
|
||||
0,
|
||||
ImageView::new_default(tex)?,
|
||||
Filter::Linear,
|
||||
app.graphics.texture_filtering,
|
||||
)?;
|
||||
let set1 = canvas
|
||||
.pipeline_fg_glyph
|
||||
@@ -809,7 +811,7 @@ impl<D, S> Control<D, S> {
|
||||
let set0 = canvas.pipeline_fg_glyph.uniform_sampler(
|
||||
0,
|
||||
ImageView::new_default(tex)?,
|
||||
Filter::Linear,
|
||||
app.graphics.texture_filtering,
|
||||
)?;
|
||||
let set1 = canvas
|
||||
.pipeline_fg_glyph
|
||||
|
||||
@@ -229,7 +229,9 @@ impl ScreenPipeline {
|
||||
.graphics
|
||||
.create_command_buffer(CommandBufferUsage::OneTimeSubmit)?;
|
||||
let view = ImageView::new_default(image)?;
|
||||
let set0 = self.pipeline.uniform_sampler(0, view, Filter::Linear)?;
|
||||
let set0 = self
|
||||
.pipeline
|
||||
.uniform_sampler(0, view, app.graphics.texture_filtering)?;
|
||||
|
||||
let pass = self.pipeline.create_pass(
|
||||
self.extentf,
|
||||
|
||||
Reference in New Issue
Block a user