Update winit example

This commit is contained in:
msiglreith 2020-06-14 23:32:59 +02:00
parent dc5facd198
commit eed71721eb
3 changed files with 17 additions and 15 deletions

View file

@ -37,7 +37,7 @@ fn main() -> Result<(), Error> {
.map(|_| device.create_cmd_buf()) .map(|_| device.create_cmd_buf())
.collect::<Result<Vec<_>, Error>>()?; .collect::<Result<Vec<_>, Error>>()?;
let query_pools = (0..NUM_FRAMES) let query_pools = (0..NUM_FRAMES)
.map(|_| device.create_query_pool(5)) .map(|_| device.create_query_pool(8))
.collect::<Result<Vec<_>, Error>>()?; .collect::<Result<Vec<_>, Error>>()?;
let mut ctx = PietGpuRenderContext::new(); let mut ctx = PietGpuRenderContext::new();
@ -70,13 +70,17 @@ fn main() -> Result<(), Error> {
if current_frame >= NUM_FRAMES { if current_frame >= NUM_FRAMES {
device.wait_and_reset(&[frame_fences[frame_idx]]).unwrap(); device.wait_and_reset(&[frame_fences[frame_idx]]).unwrap();
let timestamps = device.reap_query_pool(query_pool).unwrap(); let ts = device.reap_query_pool(query_pool).unwrap();
window.set_title(&format!( window.set_title(&format!(
"e: {:.3}ms, b: {:.3}ms, c: {:.3}ms, f: {:.3}ms", "{:.3}ms :: e:{:.3}ms|alloc:{:.3}ms|cp:{:.3}ms|bd:{:.3}ms|bin:{:.3}ms|cr:{:.3}ms|r:{:.3}ms",
timestamps[0] * 1e3, ts[6] * 1e3,
(timestamps[1] - timestamps[0]) * 1e3, ts[0] * 1e3,
(timestamps[2] - timestamps[1]) * 1e3, (ts[1] - ts[0]) * 1e3,
(timestamps[3] - timestamps[2]) * 1e3, (ts[2] - ts[1]) * 1e3,
(ts[3] - ts[2]) * 1e3,
(ts[4] - ts[3]) * 1e3,
(ts[5] - ts[4]) * 1e3,
(ts[6] - ts[5]) * 1e3,
)); ));
} }
@ -84,8 +88,6 @@ fn main() -> Result<(), Error> {
let swap_image = swapchain.image(image_idx); let swap_image = swapchain.image(image_idx);
let cmd_buf = &mut cmd_buffers[frame_idx]; let cmd_buf = &mut cmd_buffers[frame_idx];
cmd_buf.begin(); cmd_buf.begin();
cmd_buf.reset_query_pool(&query_pool);
renderer.record(cmd_buf, &query_pool); renderer.record(cmd_buf, &query_pool);
// Image -> Swapchain // Image -> Swapchain

View file

@ -8,9 +8,11 @@
#extension GL_GOOGLE_include_directive : enable #extension GL_GOOGLE_include_directive : enable
#extension GL_KHR_shader_subgroup_basic : enable #extension GL_KHR_shader_subgroup_basic : enable
#include "setup.h"
#define CHUNK 8 #define CHUNK 8
#define CHUNK_DY (16 / CHUNK) #define CHUNK_DY (TILE_HEIGHT_PX / CHUNK)
layout(local_size_x = 16, local_size_y = 2) in; layout(local_size_x = TILE_WIDTH_PX, local_size_y = CHUNK_DY) in;
// Same concern that this should be readonly as in kernel 3. // Same concern that this should be readonly as in kernel 3.
layout(set = 0, binding = 0) buffer PtclBuf { layout(set = 0, binding = 0) buffer PtclBuf {
@ -26,8 +28,6 @@ layout(rgba8, set = 0, binding = 2) uniform writeonly image2D image;
#include "ptcl.h" #include "ptcl.h"
#include "tile.h" #include "tile.h"
#include "setup.h"
void main() { void main() {
uint tile_ix = gl_WorkGroupID.y * WIDTH_IN_TILES + gl_WorkGroupID.x; uint tile_ix = gl_WorkGroupID.y * WIDTH_IN_TILES + gl_WorkGroupID.x;
CmdRef cmd_ref = CmdRef(tile_ix * PTCL_INITIAL_ALLOC); CmdRef cmd_ref = CmdRef(tile_ix * PTCL_INITIAL_ALLOC);

View file

@ -263,8 +263,8 @@ impl<D: Device> Renderer<D> {
let k4_code = include_bytes!("../shader/kernel4.spv"); let k4_code = include_bytes!("../shader/kernel4.spv");
let k4_pipeline = device.create_simple_compute_pipeline(k4_code, 2, 1)?; let k4_pipeline = device.create_simple_compute_pipeline(k4_code, 2, 1)?;
let k4_ds = device.create_descriptor_set( let k4_ds = device.create_descriptor_set(
&k4_pipeline, &k4_pipeline,
&[&ptcl_buf, &tile_buf], &[&ptcl_buf, &tile_buf],
&[&image_dev] &[&image_dev]
)?; )?;