mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
Partial DX12 fixes
As of this patch, cli works in release mode, but hangs in debug. There are some validation errors about incompatible resouce states.
This commit is contained in:
parent
c503ff28b0
commit
7f3427420b
|
@ -554,6 +554,7 @@ impl crate::backend::Device for Dx12Device {
|
||||||
Flags: d3d12::D3D12_PIPELINE_STATE_FLAG_NONE,
|
Flags: d3d12::D3D12_PIPELINE_STATE_FLAG_NONE,
|
||||||
};
|
};
|
||||||
let pipeline_state = self.device.create_compute_pipeline_state(&desc)?;
|
let pipeline_state = self.device.create_compute_pipeline_state(&desc)?;
|
||||||
|
|
||||||
Ok(Pipeline {
|
Ok(Pipeline {
|
||||||
pipeline_state,
|
pipeline_state,
|
||||||
root_signature,
|
root_signature,
|
||||||
|
@ -725,8 +726,10 @@ impl crate::backend::DescriptorSetBuilder<Dx12Device> for DescriptorSetBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_textures(&mut self, _images: &[&Image]) {
|
fn add_textures(&mut self, images: &[&Image]) {
|
||||||
todo!()
|
for img in images {
|
||||||
|
self.handles.push(img.cpu_ref.as_ref().unwrap().handle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn build(
|
unsafe fn build(
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::path::Path;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
use piet_gpu_hal::{BufferUsage, Error, Instance, Session};
|
use piet_gpu_hal::{BufferUsage, Error, Instance, InstanceFlags, Session};
|
||||||
|
|
||||||
use piet_gpu::{test_scenes, PietGpuRenderContext, Renderer};
|
use piet_gpu::{test_scenes, PietGpuRenderContext, Renderer};
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ fn main() -> Result<(), Error> {
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
let (instance, _) = Instance::new(None, Default::default())?;
|
let (instance, _) = Instance::new(None, InstanceFlags::default())?;
|
||||||
unsafe {
|
unsafe {
|
||||||
let device = instance.device(None)?;
|
let device = instance.device(None)?;
|
||||||
let session = Session::new(device);
|
let session = Session::new(device);
|
||||||
|
@ -256,6 +256,7 @@ fn main() -> Result<(), Error> {
|
||||||
cmd_buf.begin();
|
cmd_buf.begin();
|
||||||
renderer.record(&mut cmd_buf, &query_pool, 0);
|
renderer.record(&mut cmd_buf, &query_pool, 0);
|
||||||
cmd_buf.copy_image_to_buffer(&renderer.image_dev, &image_buf);
|
cmd_buf.copy_image_to_buffer(&renderer.image_dev, &image_buf);
|
||||||
|
cmd_buf.finish_timestamps(&query_pool);
|
||||||
cmd_buf.host_barrier();
|
cmd_buf.host_barrier();
|
||||||
cmd_buf.finish();
|
cmd_buf.finish();
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
|
|
|
@ -14,8 +14,8 @@ use piet::kurbo::Vec2;
|
||||||
use piet::{ImageFormat, RenderContext};
|
use piet::{ImageFormat, RenderContext};
|
||||||
|
|
||||||
use piet_gpu_hal::{
|
use piet_gpu_hal::{
|
||||||
BindType, Buffer, BufferUsage, CmdBuf, DescriptorSet, Error, Image, ImageLayout, Pipeline,
|
include_shader, BindType, Buffer, BufferUsage, CmdBuf, DescriptorSet, Error, Image,
|
||||||
QueryPool, Session, ShaderCode, include_shader,
|
ImageLayout, Pipeline, QueryPool, Session,
|
||||||
};
|
};
|
||||||
|
|
||||||
use pico_svg::PicoSvg;
|
use pico_svg::PicoSvg;
|
||||||
|
@ -63,8 +63,6 @@ pub struct Renderer {
|
||||||
memory_buf_host: Vec<Buffer>,
|
memory_buf_host: Vec<Buffer>,
|
||||||
memory_buf_dev: Buffer,
|
memory_buf_dev: Buffer,
|
||||||
|
|
||||||
state_buf: Buffer,
|
|
||||||
|
|
||||||
// Staging buffers
|
// Staging buffers
|
||||||
config_bufs: Vec<Buffer>,
|
config_bufs: Vec<Buffer>,
|
||||||
// Device config buf
|
// Device config buf
|
||||||
|
@ -125,7 +123,6 @@ impl Renderer {
|
||||||
.map(|_| session.create_buffer(8 * 1024 * 1024, host_upload).unwrap())
|
.map(|_| session.create_buffer(8 * 1024 * 1024, host_upload).unwrap())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let state_buf = session.create_buffer(1 * 1024 * 1024, dev)?;
|
|
||||||
let image_dev = session.create_image2d(width as u32, height as u32)?;
|
let image_dev = session.create_image2d(width as u32, height as u32)?;
|
||||||
|
|
||||||
// Note: this must be updated when the config struct size changes.
|
// Note: this must be updated when the config struct size changes.
|
||||||
|
@ -163,13 +160,13 @@ impl Renderer {
|
||||||
|
|
||||||
let tile_alloc_code = include_shader!(session, "../shader/gen/tile_alloc");
|
let tile_alloc_code = include_shader!(session, "../shader/gen/tile_alloc");
|
||||||
let tile_pipeline = session
|
let tile_pipeline = session
|
||||||
.create_compute_pipeline(tile_alloc_code, &[BindType::Buffer, BindType::Buffer])?;
|
.create_compute_pipeline(tile_alloc_code, &[BindType::Buffer, BindType::BufReadOnly])?;
|
||||||
let tile_ds = session
|
let tile_ds = session
|
||||||
.create_simple_descriptor_set(&tile_pipeline, &[&memory_buf_dev, &config_buf])?;
|
.create_simple_descriptor_set(&tile_pipeline, &[&memory_buf_dev, &config_buf])?;
|
||||||
|
|
||||||
let path_alloc_code = include_shader!(session, "../shader/gen/path_coarse");
|
let path_alloc_code = include_shader!(session, "../shader/gen/path_coarse");
|
||||||
let path_pipeline = session
|
let path_pipeline = session
|
||||||
.create_compute_pipeline(path_alloc_code, &[BindType::Buffer, BindType::Buffer])?;
|
.create_compute_pipeline(path_alloc_code, &[BindType::Buffer, BindType::BufReadOnly])?;
|
||||||
let path_ds = session
|
let path_ds = session
|
||||||
.create_simple_descriptor_set(&path_pipeline, &[&memory_buf_dev, &config_buf])?;
|
.create_simple_descriptor_set(&path_pipeline, &[&memory_buf_dev, &config_buf])?;
|
||||||
|
|
||||||
|
@ -180,20 +177,20 @@ impl Renderer {
|
||||||
include_shader!(session, "../shader/gen/backdrop")
|
include_shader!(session, "../shader/gen/backdrop")
|
||||||
};
|
};
|
||||||
let backdrop_pipeline = session
|
let backdrop_pipeline = session
|
||||||
.create_compute_pipeline(backdrop_code, &[BindType::Buffer, BindType::Buffer])?;
|
.create_compute_pipeline(backdrop_code, &[BindType::Buffer, BindType::BufReadOnly])?;
|
||||||
let backdrop_ds = session
|
let backdrop_ds = session
|
||||||
.create_simple_descriptor_set(&backdrop_pipeline, &[&memory_buf_dev, &config_buf])?;
|
.create_simple_descriptor_set(&backdrop_pipeline, &[&memory_buf_dev, &config_buf])?;
|
||||||
|
|
||||||
// TODO: constants
|
// TODO: constants
|
||||||
let bin_code = include_shader!(session, "../shader/gen/binning");
|
let bin_code = include_shader!(session, "../shader/gen/binning");
|
||||||
let bin_pipeline =
|
let bin_pipeline = session
|
||||||
session.create_compute_pipeline(bin_code, &[BindType::Buffer, BindType::Buffer])?;
|
.create_compute_pipeline(bin_code, &[BindType::Buffer, BindType::BufReadOnly])?;
|
||||||
let bin_ds =
|
let bin_ds =
|
||||||
session.create_simple_descriptor_set(&bin_pipeline, &[&memory_buf_dev, &config_buf])?;
|
session.create_simple_descriptor_set(&bin_pipeline, &[&memory_buf_dev, &config_buf])?;
|
||||||
|
|
||||||
let coarse_code = include_shader!(session, "../shader/gen/coarse");
|
let coarse_code = include_shader!(session, "../shader/gen/coarse");
|
||||||
let coarse_pipeline =
|
let coarse_pipeline = session
|
||||||
session.create_compute_pipeline(coarse_code, &[BindType::Buffer, BindType::Buffer])?;
|
.create_compute_pipeline(coarse_code, &[BindType::Buffer, BindType::BufReadOnly])?;
|
||||||
let coarse_ds = session
|
let coarse_ds = session
|
||||||
.create_simple_descriptor_set(&coarse_pipeline, &[&memory_buf_dev, &config_buf])?;
|
.create_simple_descriptor_set(&coarse_pipeline, &[&memory_buf_dev, &config_buf])?;
|
||||||
|
|
||||||
|
@ -215,7 +212,7 @@ impl Renderer {
|
||||||
k4_code,
|
k4_code,
|
||||||
&[
|
&[
|
||||||
BindType::Buffer,
|
BindType::Buffer,
|
||||||
BindType::Buffer,
|
BindType::BufReadOnly,
|
||||||
BindType::Image,
|
BindType::Image,
|
||||||
BindType::ImageRead,
|
BindType::ImageRead,
|
||||||
BindType::ImageRead,
|
BindType::ImageRead,
|
||||||
|
@ -234,7 +231,6 @@ impl Renderer {
|
||||||
scene_bufs,
|
scene_bufs,
|
||||||
memory_buf_host,
|
memory_buf_host,
|
||||||
memory_buf_dev,
|
memory_buf_dev,
|
||||||
state_buf,
|
|
||||||
config_buf,
|
config_buf,
|
||||||
config_bufs,
|
config_bufs,
|
||||||
image_dev,
|
image_dev,
|
||||||
|
@ -324,7 +320,6 @@ impl Renderer {
|
||||||
pub unsafe fn record(&self, cmd_buf: &mut CmdBuf, query_pool: &QueryPool, buf_ix: usize) {
|
pub unsafe fn record(&self, cmd_buf: &mut CmdBuf, query_pool: &QueryPool, buf_ix: usize) {
|
||||||
cmd_buf.copy_buffer(&self.config_bufs[buf_ix], &self.config_buf);
|
cmd_buf.copy_buffer(&self.config_bufs[buf_ix], &self.config_buf);
|
||||||
cmd_buf.copy_buffer(&self.memory_buf_host[buf_ix], &self.memory_buf_dev);
|
cmd_buf.copy_buffer(&self.memory_buf_host[buf_ix], &self.memory_buf_dev);
|
||||||
cmd_buf.clear_buffer(&self.state_buf, None);
|
|
||||||
cmd_buf.memory_barrier();
|
cmd_buf.memory_barrier();
|
||||||
cmd_buf.image_barrier(
|
cmd_buf.image_barrier(
|
||||||
&self.image_dev,
|
&self.image_dev,
|
||||||
|
@ -386,7 +381,9 @@ impl Renderer {
|
||||||
(256, 1, 1),
|
(256, 1, 1),
|
||||||
);
|
);
|
||||||
cmd_buf.write_timestamp(&query_pool, 5);
|
cmd_buf.write_timestamp(&query_pool, 5);
|
||||||
|
println!("before barrier");
|
||||||
cmd_buf.memory_barrier();
|
cmd_buf.memory_barrier();
|
||||||
|
println!("after barrier, before coarse");
|
||||||
cmd_buf.dispatch(
|
cmd_buf.dispatch(
|
||||||
&self.coarse_pipeline,
|
&self.coarse_pipeline,
|
||||||
&self.coarse_ds,
|
&self.coarse_ds,
|
||||||
|
@ -397,6 +394,7 @@ impl Renderer {
|
||||||
),
|
),
|
||||||
(256, 256, 1),
|
(256, 256, 1),
|
||||||
);
|
);
|
||||||
|
println!("after coarse");
|
||||||
cmd_buf.write_timestamp(&query_pool, 6);
|
cmd_buf.write_timestamp(&query_pool, 6);
|
||||||
cmd_buf.memory_barrier();
|
cmd_buf.memory_barrier();
|
||||||
cmd_buf.dispatch(
|
cmd_buf.dispatch(
|
||||||
|
|
Loading…
Reference in a new issue