From ce6059d30daa2e2ce3c196269d539d592b047cc3 Mon Sep 17 00:00:00 2001 From: Yury Date: Mon, 4 Nov 2024 19:44:11 +0300 Subject: [PATCH] Rename gpu_resource_id to gpu_res_id --- cidre/src/mtl.rs | 2 +- cidre/src/mtl/acceleration_structure.rs | 2 +- cidre/src/mtl/compute_pipeline.rs | 2 +- cidre/src/mtl/indirect_command_buffer.rs | 2 +- cidre/src/mtl/intersection_function_table.rs | 2 +- cidre/src/mtl/render_pipeline.rs | 2 +- cidre/src/mtl/sampler.rs | 2 +- cidre/src/mtl/texture.rs | 2 +- cidre/src/mtl/types.rs | 18 ++++++++++++++++++ cidre/src/mtl/visible_function_table.rs | 2 +- 10 files changed, 27 insertions(+), 9 deletions(-) diff --git a/cidre/src/mtl.rs b/cidre/src/mtl.rs index 89bb9415..842ec95f 100644 --- a/cidre/src/mtl.rs +++ b/cidre/src/mtl.rs @@ -329,7 +329,7 @@ macro_rules! define_mtl { pub fn set_depth(&mut self, val: usize); }; - (gpu_resource_id) => { + (gpu_res_id) => { #[$crate::objc::msg_send(gpuResourceID)] pub fn gpu_resource_id(&self) -> crate::mtl::ResId; }; diff --git a/cidre/src/mtl/acceleration_structure.rs b/cidre/src/mtl/acceleration_structure.rs index 859584a8..bfa330bd 100644 --- a/cidre/src/mtl/acceleration_structure.rs +++ b/cidre/src/mtl/acceleration_structure.rs @@ -194,7 +194,7 @@ impl AccelerationStructure { #[objc::msg_send(size)] pub fn size(&self) -> usize; - define_mtl!(gpu_resource_id); + define_mtl!(gpu_res_id); } extern "C" { diff --git a/cidre/src/mtl/compute_pipeline.rs b/cidre/src/mtl/compute_pipeline.rs index 1abdebb8..1bf148ed 100644 --- a/cidre/src/mtl/compute_pipeline.rs +++ b/cidre/src/mtl/compute_pipeline.rs @@ -54,7 +54,7 @@ define_obj_type!( ); impl State { - define_mtl!(gpu_resource_id); + define_mtl!(gpu_res_id); #[objc::msg_send(device)] pub fn device(&self) -> arc::R; diff --git a/cidre/src/mtl/indirect_command_buffer.rs b/cidre/src/mtl/indirect_command_buffer.rs index 6a9f88a2..f33b338a 100644 --- a/cidre/src/mtl/indirect_command_buffer.rs +++ b/cidre/src/mtl/indirect_command_buffer.rs @@ -102,7 +102,7 @@ define_obj_type!( ); impl IndirectCmdBuf { - define_mtl!(gpu_resource_id); + define_mtl!(gpu_res_id); #[objc::msg_send(size)] pub fn size(&self) -> usize; diff --git a/cidre/src/mtl/intersection_function_table.rs b/cidre/src/mtl/intersection_function_table.rs index dc77bf6e..54f096bc 100644 --- a/cidre/src/mtl/intersection_function_table.rs +++ b/cidre/src/mtl/intersection_function_table.rs @@ -59,7 +59,7 @@ impl Desc { define_obj_type!(pub IntersectionFnTable(mtl::Res)); impl IntersectionFnTable { - define_mtl!(gpu_resource_id); + define_mtl!(gpu_res_id); #[objc::msg_send(setBuffer:atIndex:)] pub fn set_buf_at(&mut self, buf: Option<&mtl::Buf>, index: usize); diff --git a/cidre/src/mtl/render_pipeline.rs b/cidre/src/mtl/render_pipeline.rs index 4b25fe1d..b8516074 100644 --- a/cidre/src/mtl/render_pipeline.rs +++ b/cidre/src/mtl/render_pipeline.rs @@ -250,7 +250,7 @@ define_obj_type!(pub FnsDesc(ns::Id)); define_obj_type!(pub State(ns::Id)); impl State { - define_mtl!(gpu_resource_id); + define_mtl!(gpu_res_id); #[objc::msg_send(device)] pub fn device(&self) -> arc::R; diff --git a/cidre/src/mtl/sampler.rs b/cidre/src/mtl/sampler.rs index 4aa2f2fd..97d37735 100644 --- a/cidre/src/mtl/sampler.rs +++ b/cidre/src/mtl/sampler.rs @@ -82,7 +82,7 @@ define_obj_type!( pub State(ns::Id)); impl State { - define_mtl!(gpu_resource_id); + define_mtl!(gpu_res_id); #[objc::msg_send(device)] pub fn device(&self) -> arc::R; diff --git a/cidre/src/mtl/texture.rs b/cidre/src/mtl/texture.rs index 3c390c56..a8fd03bc 100644 --- a/cidre/src/mtl/texture.rs +++ b/cidre/src/mtl/texture.rs @@ -268,7 +268,7 @@ define_obj_type!( ); impl Texture { - define_mtl!(width, height, depth, gpu_resource_id); + define_mtl!(width, height, depth, gpu_res_id); /// The texture this texture view was created from, or [`None`] if this is not /// a texture view or it was not created from a texture. diff --git a/cidre/src/mtl/types.rs b/cidre/src/mtl/types.rs index fea38f26..9283299c 100644 --- a/cidre/src/mtl/types.rs +++ b/cidre/src/mtl/types.rs @@ -8,6 +8,17 @@ pub struct Size { pub depth: ns::UInteger, } +impl Size { + #[inline] + pub fn _2d(width: usize, height: usize) -> Self { + Self { + width, + height, + depth: 1, + } + } +} + #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[repr(C)] pub struct Origin { @@ -16,6 +27,13 @@ pub struct Origin { pub z: usize, } +impl Origin { + #[inline] + pub fn zero() -> Self { + Self::default() + } +} + /// Handle of the GPU resource suitable for storing in an Argument Buffer #[doc(alias = "MTLResourceID")] #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] diff --git a/cidre/src/mtl/visible_function_table.rs b/cidre/src/mtl/visible_function_table.rs index 2ad2f297..ff722480 100644 --- a/cidre/src/mtl/visible_function_table.rs +++ b/cidre/src/mtl/visible_function_table.rs @@ -24,7 +24,7 @@ define_obj_type!( ); impl VisibleFnTable { - define_mtl!(gpu_resource_id); + define_mtl!(gpu_res_id); /// Sets a table entry to point to a callable function. #[objc::msg_send(setFunction:atIndex:)]