Put the program's render encoder in front of its lowering

Content: the tree of `development` at 12dcaf3df6, unchanged.
This commit is contained in:
Anees Iqbal committed 2026-10-26 13:19:04 +02:00
1 parent d218c939a4
commit d6fcaef151
21 files changed
+1823 -705

No files matched your search

+63 -16
View File
@@ -48,6 +48,7 @@ use super::compute::ComputeCommandEncoder;
use super::error::Error;
use super::render::RenderCall;
use super::render::RenderCommandEncoder;
use super::render::RenderLowering;
use super::replay::BlitCall;
use super::texture::Texture;
@@ -281,63 +282,109 @@ impl ComputeCommandEncoder {
pub fn insert_compressed_texture_reinterpretation_flush(&mut self) {}
}
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::set_alpha_test_reference_value`].
pub(crate) fn set_alpha_test_reference_value(&mut self, value: f32) -> Result<(), Error> {
self.log(|_| RenderCall::AlphaTestReferenceValue(value));
answer(AppleOnlyCall::SetAlphaTestReferenceValue(value))
}
/// The lowering of [`RenderCommandEncoder::set_line_width`].
pub(crate) fn set_line_width(&mut self, width: f32) -> Result<(), Error> {
self.log(|_| RenderCall::LineWidth(width));
answer(AppleOnlyCall::SetLineWidth(width))
}
/// The lowering of [`RenderCommandEncoder::set_point_size`].
pub(crate) fn set_point_size(&mut self, size: f32) -> Result<(), Error> {
self.log(|_| RenderCall::PointSize(size));
answer(AppleOnlyCall::SetPointSize(size))
}
/// The lowering of [`RenderCommandEncoder::set_provoking_vertex_mode`].
pub(crate) fn set_provoking_vertex_mode(&mut self, mode: u64) -> Result<(), Error> {
self.log(|_| RenderCall::ProvokingVertexMode(mode));
answer(AppleOnlyCall::SetProvokingVertexMode(mode))
}
/// The lowering of [`RenderCommandEncoder::set_viewport_transform_enabled`].
pub(crate) fn set_viewport_transform_enabled(&mut self, enabled: bool) -> Result<(), Error> {
self.log(|_| RenderCall::ViewportTransformEnabled(enabled));
answer(AppleOnlyCall::SetViewportTransformEnabled(enabled))
}
/// The lowering of [`RenderCommandEncoder::set_vertex_amplification_mode`].
pub(crate) fn set_vertex_amplification_mode(
&mut self,
mode: u64,
value: u64,
) -> Result<(), Error> {
self.log(|_| RenderCall::VertexAmplificationMode(mode, value));
answer(AppleOnlyCall::SetVertexAmplificationMode { mode, value })
}
/// The lowering of [`RenderCommandEncoder::set_depth_cleared`].
pub(crate) fn set_depth_cleared(&mut self) -> Result<(), Error> {
self.log(|_| RenderCall::DepthCleared);
answer(AppleOnlyCall::SetDepthCleared)
}
/// The lowering of [`RenderCommandEncoder::set_stencil_cleared`].
pub(crate) fn set_stencil_cleared(&mut self) -> Result<(), Error> {
self.log(|_| RenderCall::StencilCleared);
answer(AppleOnlyCall::SetStencilCleared)
}
}
impl RenderCommandEncoder {
/// `setAlphaTestReferenceValue:` (SPI): a no-op. No pipeline the runtime builds has a
/// fixed-function alpha test, so the reference has no effect, as on Metal with the test off.
pub fn set_alpha_test_reference_value(&mut self, value: f32) -> Result<(), Error> {
self.log(|_| RenderCall::AlphaTestReferenceValue(value));
answer(AppleOnlyCall::SetAlphaTestReferenceValue(value))
self.lowering.set_alpha_test_reference_value(value)
}
/// `setLineWidth:` (SPI): accepted at Metal's default width of 1, which every line the
/// runtime draws has; any other width is refused ([`AppleOnly::LineWidth`]): Apple's
/// wide-line rule is unmeasured.
pub fn set_line_width(&mut self, width: f32) -> Result<(), Error> {
self.log(|_| RenderCall::LineWidth(width));
answer(AppleOnlyCall::SetLineWidth(width))
self.lowering.set_line_width(width)
}
/// `setPointSize:` (SPI): a no-op. On an M4 it changes nothing Metal draws at any size (0,
/// 0.5, 1, 3, 5, 100, -2, NaN, infinity), whether the vertex function writes `[[point_size]]`
/// or not and whether the pipeline's private `pointSizeOutputVS` is set.
pub fn set_point_size(&mut self, size: f32) -> Result<(), Error> {
self.log(|_| RenderCall::PointSize(size));
answer(AppleOnlyCall::SetPointSize(size))
self.lowering.set_point_size(size)
}
/// `setProvokingVertexMode:` (SPI): accepted at Metal's default, mode 0, the first vertex,
/// from which every runtime draw takes a flat varying; any other mode is refused
/// ([`AppleOnly::ProvokingVertexMode`]).
pub fn set_provoking_vertex_mode(&mut self, mode: u64) -> Result<(), Error> {
self.log(|_| RenderCall::ProvokingVertexMode(mode));
answer(AppleOnlyCall::SetProvokingVertexMode(mode))
self.lowering.set_provoking_vertex_mode(mode)
}
/// `setViewportTransformEnabled:` (SPI): accepted on, Metal's default and every runtime
/// draw's; off is refused ([`AppleOnly::ViewportTransformDisabled`]): Vulkan has no form for
/// it.
pub fn set_viewport_transform_enabled(&mut self, enabled: bool) -> Result<(), Error> {
self.log(|_| RenderCall::ViewportTransformEnabled(enabled));
answer(AppleOnlyCall::SetViewportTransformEnabled(enabled))
self.lowering.set_viewport_transform_enabled(enabled)
}
/// `setVertexAmplificationMode:value:` (SPI): refused
/// ([`AppleOnly::VertexAmplificationMode`]), its meaning unmeasured.
pub fn set_vertex_amplification_mode(&mut self, mode: u64, value: u64) -> Result<(), Error> {
self.log(|_| RenderCall::VertexAmplificationMode(mode, value));
answer(AppleOnlyCall::SetVertexAmplificationMode { mode, value })
self.lowering.set_vertex_amplification_mode(mode, value)
}
/// `setDepthCleared` (SPI): refused ([`AppleOnly::DepthCleared`]), its meaning unmeasured.
pub fn set_depth_cleared(&mut self) -> Result<(), Error> {
self.log(|_| RenderCall::DepthCleared);
answer(AppleOnlyCall::SetDepthCleared)
self.lowering.set_depth_cleared()
}
/// `setStencilCleared` (SPI): refused ([`AppleOnly::StencilCleared`]), its meaning
/// unmeasured.
pub fn set_stencil_cleared(&mut self) -> Result<(), Error> {
self.log(|_| RenderCall::StencilCleared);
answer(AppleOnlyCall::SetStencilCleared)
self.lowering.set_stencil_cleared()
}
}
+73 -30
View File
@@ -64,6 +64,7 @@ use super::error::Error;
use super::predication::Event;
use super::render::RenderCall;
use super::render::RenderCommandEncoder;
use super::render::RenderLowering;
use super::render::{FRAGMENT_DRAW_STAGES, GEOMETRY_DRAW_STAGES};
use super::replay::{BlitCall, ComputeCall, Resource};
use super::resource::{ResourceKey, ResourceRef};
@@ -276,11 +277,13 @@ const UP_TO_FRAGMENT: RenderStages = RenderStages::VERTEX
.union(RenderStages::MESH)
.union(RenderStages::FRAGMENT);
impl RenderCommandEncoder {
/// `updateFence:afterStages:`: the fence is updated after the encoder's draws' work in
/// `after_stages` and every stage before them (the module docs), and its work outside its
/// draws; Metal's `Tile` stage, or no stage, after all of its work.
pub fn update_fence(&mut self, fence: &Fence, after_stages: RenderStages) -> Result<(), Error> {
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::update_fence`].
pub(crate) fn update_fence(
&mut self,
fence: &Fence,
after_stages: RenderStages,
) -> Result<(), Error> {
self.log(|_| RenderCall::UpdateFence(fence.clone(), after_stages));
// The update follows the encoder's work, its later color groups' passes too, which
// record in its core after the first group's: their encoders' calls change nothing
@@ -292,13 +295,8 @@ impl RenderCommandEncoder {
.update_fence("update_fence", fence, after_stages_of(after_stages))
}
/// `waitForFence:beforeStages:`: the encoder's draws' work in `before_stages` and every stage
/// after them waits for the fence's last update before the encoder in the queue's commit
/// order, also after the encoder updated the fence, as the compute encoder's does, and so
/// does its work outside its draws (the module docs); its draws' earlier stages may run
/// before the update. A wait before the vertex, object or mesh stage, or before no stage,
/// orders all of its work.
pub fn wait_for_fence(
/// The lowering of [`RenderCommandEncoder::wait_for_fence`].
pub(crate) fn wait_for_fence(
&mut self,
fence: &Fence,
before_stages: RenderStages,
@@ -313,18 +311,8 @@ impl RenderCommandEncoder {
.wait_for_fence("wait_for_fence", fence, before_stages_of(before_stages))
}
/// `memoryBarrierWithScope:afterStages:beforeStages:`: the writes of the encoder's draws
/// before the barrier to the kinds of resource `scope` names (buffers, textures, render
/// targets) are visible to its draws after it (the module docs). A scope of the render
/// targets alone, after the fragment stage and before a stage at or before it (the vertex,
/// object, mesh or fragment stage), orders the fragment stage's writes before the later
/// draws' fragment stages, which run after their earlier stages, inside the render pass
/// instance; another scope splits the pass there. An empty scope, no stage before or after,
/// or a scope of the render targets alone after no fragment stage or before none of those
/// stages orders nothing more than the pass does: only the fragment stage writes a render
/// target, and a tile dispatch runs between render pass instances
/// (`render/tile_dispatch.rs`).
pub fn memory_barrier_with_scope(
/// The lowering of [`RenderCommandEncoder::memory_barrier_with_scope`].
pub(crate) fn memory_barrier_with_scope(
&mut self,
scope: BarrierScope,
after_stages: RenderStages,
@@ -345,12 +333,8 @@ impl RenderCommandEncoder {
self.barrier_before_next_draw();
}
/// `memoryBarrierWithResources:count:afterStages:beforeStages:`: as
/// [`memory_barrier_with_scope`](Self::memory_barrier_with_scope) over buffers and textures,
/// for the writes to `resources`, which splits the pass; an empty list orders nothing.
///
/// Refused, changing nothing (`Invalid`): a resource of another device.
pub fn memory_barrier_with_resources(
/// The lowering of [`RenderCommandEncoder::memory_barrier_with_resources`].
pub(crate) fn memory_barrier_with_resources(
&mut self,
resources: &[ResourceRef<'_>],
after_stages: RenderStages,
@@ -369,3 +353,62 @@ impl RenderCommandEncoder {
Ok(())
}
}
impl RenderCommandEncoder {
/// `updateFence:afterStages:`: the fence is updated after the encoder's draws' work in
/// `after_stages` and every stage before them (the module docs), and its work outside its
/// draws; Metal's `Tile` stage, or no stage, after all of its work.
pub fn update_fence(&mut self, fence: &Fence, after_stages: RenderStages) -> Result<(), Error> {
self.lowering.update_fence(fence, after_stages)
}
/// `waitForFence:beforeStages:`: the encoder's draws' work in `before_stages` and every stage
/// after them waits for the fence's last update before the encoder in the queue's commit
/// order, also after the encoder updated the fence, as the compute encoder's does, and so
/// does its work outside its draws (the module docs); its draws' earlier stages may run
/// before the update. A wait before the vertex, object or mesh stage, or before no stage,
/// orders all of its work.
pub fn wait_for_fence(
&mut self,
fence: &Fence,
before_stages: RenderStages,
) -> Result<(), Error> {
self.lowering.wait_for_fence(fence, before_stages)
}
/// `memoryBarrierWithScope:afterStages:beforeStages:`: the writes of the encoder's draws
/// before the barrier to the kinds of resource `scope` names (buffers, textures, render
/// targets) are visible to its draws after it (the module docs). A scope of the render
/// targets alone, after the fragment stage and before a stage at or before it (the vertex,
/// object, mesh or fragment stage), orders the fragment stage's writes before the later
/// draws' fragment stages, which run after their earlier stages, inside the render pass
/// instance; another scope splits the pass there. An empty scope, no stage before or after,
/// or a scope of the render targets alone after no fragment stage or before none of those
/// stages orders nothing more than the pass does: only the fragment stage writes a render
/// target, and a tile dispatch runs between render pass instances
/// (`render/tile_dispatch.rs`).
pub fn memory_barrier_with_scope(
&mut self,
scope: BarrierScope,
after_stages: RenderStages,
before_stages: RenderStages,
) {
self.lowering
.memory_barrier_with_scope(scope, after_stages, before_stages)
}
/// `memoryBarrierWithResources:count:afterStages:beforeStages:`: as
/// [`memory_barrier_with_scope`](Self::memory_barrier_with_scope) over buffers and textures,
/// for the writes to `resources`, which splits the pass; an empty list orders nothing.
///
/// Refused, changing nothing (`Invalid`): a resource of another device.
pub fn memory_barrier_with_resources(
&mut self,
resources: &[ResourceRef<'_>],
after_stages: RenderStages,
before_stages: RenderStages,
) -> Result<(), Error> {
self.lowering
.memory_barrier_with_resources(resources, after_stages, before_stages)
}
}
File diff suppressed because it is too large. Load diff
@@ -25,6 +25,7 @@
//! dispatch (`render/shadows.rs`).
use super::RenderCommandEncoder;
use super::RenderLowering;
use super::{RenderCall, Table};
use crate::error::Error;
use crate::function_table::VisibleFunctionTable;
@@ -34,13 +35,9 @@ use crate::replay::Resource;
use crate::resource::ResourceRef;
use metal2vulkan::metal::{RenderStages, ResourceUsage};
impl RenderCommandEncoder {
/// `useResource:usage:stages:`: the encoder's later draws and tile dispatches may reach
/// `resource` in render `stages` through an address or a resource ID held in memory, reading
/// or writing as `usage` says (the module docs).
///
/// Refused, changing nothing: a resource of another device (`Invalid`).
pub fn use_resource(
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::use_resource`].
pub(crate) fn use_resource(
&mut self,
resource: ResourceRef<'_>,
usage: ResourceUsage,
@@ -50,9 +47,8 @@ impl RenderCommandEncoder {
self.use_all("use_resource", &[resource], usage, stages)
}
/// `useResources:count:usage:stages:`: [`use_resource`](Self::use_resource) of each of
/// `resources`, refused, changing nothing, as it is for any of them.
pub fn use_resources(
/// The lowering of [`RenderCommandEncoder::use_resources`].
pub(crate) fn use_resources(
&mut self,
resources: &[ResourceRef<'_>],
usage: ResourceUsage,
@@ -85,23 +81,14 @@ impl RenderCommandEncoder {
Ok(())
}
/// `useHeap:stages:`: the encoder's later draws and tile dispatches may read every buffer
/// placed in `heap` in render `stages` through an address held in memory, and every texture
/// made in it or over a buffer placed in it through its resource ID, as Metal's contract makes
/// a heap's resources resident for reading only (`residency.rs`): the textures that live now,
/// and each made later, from the first command encoded after it is made.
///
/// A sparse heap's live sparse textures are made resident, as on a compute encoder.
///
/// Refused, changing nothing (`Invalid`): a heap of another device.
pub fn use_heap(&mut self, heap: &Heap, stages: RenderStages) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::use_heap`].
pub(crate) fn use_heap(&mut self, heap: &Heap, stages: RenderStages) -> Result<(), Error> {
self.log(|_| RenderCall::UseHeap(heap.clone(), stages));
self.use_heaps_of("use_heap", &[heap], stages)
}
/// `useHeaps:count:stages:`: [`use_heap`](Self::use_heap) of each of `heaps`, refused,
/// changing nothing, as it is for any of them.
pub fn use_heaps(&mut self, heaps: &[&Heap], stages: RenderStages) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::use_heaps`].
pub(crate) fn use_heaps(&mut self, heaps: &[&Heap], stages: RenderStages) -> Result<(), Error> {
self.log(|_| {
RenderCall::UseHeaps(heaps.iter().map(|&heap| heap.clone()).collect(), stages)
});
@@ -166,13 +153,54 @@ impl RenderCommandEncoder {
}
impl RenderCommandEncoder {
/// `setVertexVisibleFunctionTable:atBufferIndex:` (`None` unbinds the index): the table at
/// the vertex stage's buffer index `index`, in place of any buffer there, as a compute
/// encoder's `set_visible_function_table` binds one (`function_table.rs`). Refused: an index
/// past the buffer table, a table of another device. A draw whose vertex function reads a
/// buffer at the index, or a table where a buffer is bound, is refused
/// (`Invalid(FunctionTable)`), as Metal's validation stops it.
pub fn set_vertex_visible_function_table(
/// `useResource:usage:stages:`: the encoder's later draws and tile dispatches may reach
/// `resource` in render `stages` through an address or a resource ID held in memory, reading
/// or writing as `usage` says (the module docs).
///
/// Refused, changing nothing: a resource of another device (`Invalid`).
pub fn use_resource(
&mut self,
resource: ResourceRef<'_>,
usage: ResourceUsage,
stages: RenderStages,
) -> Result<(), Error> {
self.lowering.use_resource(resource, usage, stages)
}
/// `useResources:count:usage:stages:`: [`use_resource`](Self::use_resource) of each of
/// `resources`, refused, changing nothing, as it is for any of them.
pub fn use_resources(
&mut self,
resources: &[ResourceRef<'_>],
usage: ResourceUsage,
stages: RenderStages,
) -> Result<(), Error> {
self.lowering.use_resources(resources, usage, stages)
}
/// `useHeap:stages:`: the encoder's later draws and tile dispatches may read every buffer
/// placed in `heap` in render `stages` through an address held in memory, and every texture
/// made in it or over a buffer placed in it through its resource ID, as Metal's contract makes
/// a heap's resources resident for reading only (`residency.rs`): the textures that live now,
/// and each made later, from the first command encoded after it is made.
///
/// A sparse heap's live sparse textures are made resident, as on a compute encoder.
///
/// Refused, changing nothing (`Invalid`): a heap of another device.
pub fn use_heap(&mut self, heap: &Heap, stages: RenderStages) -> Result<(), Error> {
self.lowering.use_heap(heap, stages)
}
/// `useHeaps:count:stages:`: [`use_heap`](Self::use_heap) of each of `heaps`, refused,
/// changing nothing, as it is for any of them.
pub fn use_heaps(&mut self, heaps: &[&Heap], stages: RenderStages) -> Result<(), Error> {
self.lowering.use_heaps(heaps, stages)
}
}
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::set_vertex_visible_function_table`].
pub(crate) fn set_vertex_visible_function_table(
&mut self,
table: Option<&VisibleFunctionTable>,
index: u32,
@@ -183,11 +211,8 @@ impl RenderCommandEncoder {
.set_function_tables(&mut self.core, CALL, &[table], index)
}
/// `setVertexVisibleFunctionTables:withBufferRange:`: `tables[i]` at the vertex stage's
/// buffer index `first + i`, refused as
/// [`set_vertex_visible_function_table`](Self::set_vertex_visible_function_table) is; a
/// refusal binds none of them.
pub fn set_vertex_visible_function_tables(
/// The lowering of [`RenderCommandEncoder::set_vertex_visible_function_tables`].
pub(crate) fn set_vertex_visible_function_tables(
&mut self,
tables: &[Option<&VisibleFunctionTable>],
first: u32,
@@ -204,10 +229,8 @@ impl RenderCommandEncoder {
.set_function_tables(&mut self.core, CALL, tables, first)
}
/// `setFragmentVisibleFunctionTable:atBufferIndex:`: as
/// [`set_vertex_visible_function_table`](Self::set_vertex_visible_function_table), at the
/// fragment stage's buffer index.
pub fn set_fragment_visible_function_table(
/// The lowering of [`RenderCommandEncoder::set_fragment_visible_function_table`].
pub(crate) fn set_fragment_visible_function_table(
&mut self,
table: Option<&VisibleFunctionTable>,
index: u32,
@@ -218,10 +241,8 @@ impl RenderCommandEncoder {
.set_function_tables(&mut self.core, CALL, &[table], index)
}
/// `setFragmentVisibleFunctionTables:withBufferRange:`: as
/// [`set_vertex_visible_function_tables`](Self::set_vertex_visible_function_tables), at the
/// fragment stage's buffer indices.
pub fn set_fragment_visible_function_tables(
/// The lowering of [`RenderCommandEncoder::set_fragment_visible_function_tables`].
pub(crate) fn set_fragment_visible_function_tables(
&mut self,
tables: &[Option<&VisibleFunctionTable>],
first: u32,
@@ -238,10 +259,8 @@ impl RenderCommandEncoder {
.set_function_tables(&mut self.core, CALL, tables, first)
}
/// `setTileVisibleFunctionTable:atBufferIndex:`: as
/// [`set_vertex_visible_function_table`](Self::set_vertex_visible_function_table), at the
/// tile stage's buffer index, which tile dispatches read.
pub fn set_tile_visible_function_table(
/// The lowering of [`RenderCommandEncoder::set_tile_visible_function_table`].
pub(crate) fn set_tile_visible_function_table(
&mut self,
table: Option<&VisibleFunctionTable>,
index: u32,
@@ -252,10 +271,8 @@ impl RenderCommandEncoder {
.set_function_tables(&mut self.core, CALL, &[table], index)
}
/// `setTileVisibleFunctionTables:withBufferRange:`: as
/// [`set_vertex_visible_function_tables`](Self::set_vertex_visible_function_tables), at the
/// tile stage's buffer indices.
pub fn set_tile_visible_function_tables(
/// The lowering of [`RenderCommandEncoder::set_tile_visible_function_tables`].
pub(crate) fn set_tile_visible_function_tables(
&mut self,
tables: &[Option<&VisibleFunctionTable>],
first: u32,
@@ -272,3 +289,80 @@ impl RenderCommandEncoder {
.set_function_tables(&mut self.core, CALL, tables, first)
}
}
impl RenderCommandEncoder {
/// `setVertexVisibleFunctionTable:atBufferIndex:` (`None` unbinds the index): the table at
/// the vertex stage's buffer index `index`, in place of any buffer there, as a compute
/// encoder's `set_visible_function_table` binds one (`function_table.rs`). Refused: an index
/// past the buffer table, a table of another device. A draw whose vertex function reads a
/// buffer at the index, or a table where a buffer is bound, is refused
/// (`Invalid(FunctionTable)`), as Metal's validation stops it.
pub fn set_vertex_visible_function_table(
&mut self,
table: Option<&VisibleFunctionTable>,
index: u32,
) -> Result<(), Error> {
self.lowering
.set_vertex_visible_function_table(table, index)
}
/// `setVertexVisibleFunctionTables:withBufferRange:`: `tables[i]` at the vertex stage's
/// buffer index `first + i`, refused as
/// [`set_vertex_visible_function_table`](Self::set_vertex_visible_function_table) is; a
/// refusal binds none of them.
pub fn set_vertex_visible_function_tables(
&mut self,
tables: &[Option<&VisibleFunctionTable>],
first: u32,
) -> Result<(), Error> {
self.lowering
.set_vertex_visible_function_tables(tables, first)
}
/// `setFragmentVisibleFunctionTable:atBufferIndex:`: as
/// [`set_vertex_visible_function_table`](Self::set_vertex_visible_function_table), at the
/// fragment stage's buffer index.
pub fn set_fragment_visible_function_table(
&mut self,
table: Option<&VisibleFunctionTable>,
index: u32,
) -> Result<(), Error> {
self.lowering
.set_fragment_visible_function_table(table, index)
}
/// `setFragmentVisibleFunctionTables:withBufferRange:`: as
/// [`set_vertex_visible_function_tables`](Self::set_vertex_visible_function_tables), at the
/// fragment stage's buffer indices.
pub fn set_fragment_visible_function_tables(
&mut self,
tables: &[Option<&VisibleFunctionTable>],
first: u32,
) -> Result<(), Error> {
self.lowering
.set_fragment_visible_function_tables(tables, first)
}
/// `setTileVisibleFunctionTable:atBufferIndex:`: as
/// [`set_vertex_visible_function_table`](Self::set_vertex_visible_function_table), at the
/// tile stage's buffer index, which tile dispatches read.
pub fn set_tile_visible_function_table(
&mut self,
table: Option<&VisibleFunctionTable>,
index: u32,
) -> Result<(), Error> {
self.lowering.set_tile_visible_function_table(table, index)
}
/// `setTileVisibleFunctionTables:withBufferRange:`: as
/// [`set_vertex_visible_function_tables`](Self::set_vertex_visible_function_tables), at the
/// tile stage's buffer indices.
pub fn set_tile_visible_function_tables(
&mut self,
tables: &[Option<&VisibleFunctionTable>],
first: u32,
) -> Result<(), Error> {
self.lowering
.set_tile_visible_function_tables(tables, first)
}
}
@@ -43,7 +43,7 @@
use super::bound::Bound;
use super::reroute::Rerecord;
use super::shadows::InstanceShadows;
use super::{Assembly, Instance, InterlockedStorage, RenderCommandEncoder};
use super::{Assembly, Instance, InterlockedStorage, RenderLowering};
use crate::attachmentless;
use crate::binding::CommandUses;
use crate::clear_reach::{DrawnArea, DrawnTiles, PassReach};
@@ -182,7 +182,7 @@ struct Placed {
culls: bool,
}
impl RenderCommandEncoder {
impl RenderLowering {
/// Keep the draw just recorded (`call` of `assembly` and `draw`, its indices from `index`)
/// for capture replay where the pass keeps its draws and `capturable` (the module docs);
/// otherwise the pass keeps none from here on. A draw recorded again (a reroute's, or a
@@ -78,7 +78,7 @@
use super::capture;
use super::extended_shadow::ExtendedShadows;
use super::{
reads_handles, DrawingState, Opening, RenderCommandEncoder, RenderLog, RenderPipelineState,
reads_handles, DrawingState, Opening, RenderLog, RenderLowering, RenderPipelineState,
RenderStateKind,
};
use crate::attachment_stand_in::{self, StandInCopies};
@@ -444,7 +444,7 @@ impl Ended {
.as_ref()
.ok_or_else(|| internal("a pass of several color groups without its log"))?;
for group in 1..later.group.groups() {
let mut encoder = RenderCommandEncoder::later_group(core, &later, group, log)?;
let mut encoder = RenderLowering::later_group(core, &later, group, log)?;
log.replay_into(&mut encoder);
if encoder.group_diverged() {
return Err(internal(
@@ -461,7 +461,7 @@ impl Ended {
}
}
impl RenderCommandEncoder {
impl RenderLowering {
/// The encoder of later group `group` of the pass `later` and `log` describe, over `core`
/// (the module docs).
fn later_group(
@@ -469,7 +469,7 @@ impl RenderCommandEncoder {
later: &Later,
group: u32,
log: &RenderLog,
) -> Result<RenderCommandEncoder, Error> {
) -> Result<RenderLowering, Error> {
const CALL: &str = "end_encoding";
let grouping = ColorGroup::of(later.group.present.clone(), later.group.width, group)
.ok_or_else(|| internal("a later color group of a pass in one"))?;
@@ -500,7 +500,7 @@ impl RenderCommandEncoder {
counting: false,
})),
);
Ok(RenderCommandEncoder::assemble(core, draws, opening))
Ok(RenderLowering::assemble(core, draws, opening))
}
/// Whether a later group's decisive call ran otherwise than the first group's.
@@ -257,9 +257,10 @@ use super::pending_tile::TilePipelines;
use super::shadows::InstanceShadows;
use super::tile_memory::TileMemory;
use super::RenderCall;
use super::RenderCommandEncoder;
use super::{
index_size, Assembly, Before, DrawBuffers, DrawingState, IndexedDraw, Instance,
InterlockedStorage, Next, PatchDraw, PendingDraw, Piece, RenderCommandEncoder, RenderStateKind,
InterlockedStorage, Next, PatchDraw, PendingDraw, Piece, RenderLowering, RenderStateKind,
PASS_DRAW_STAGES,
};
use crate::amplification::Amplification;
@@ -337,31 +338,9 @@ enum Inherited {
Faults,
}
impl RenderCommandEncoder {
/// `executeCommandsInBuffer:withRange:`: run render commands `range` of `icb` here, as their
/// records stand when the command buffer is committed, or, where an encoder made `icb`
/// resident for writing, once the work before them completed (a host step the device
/// announces once, `Degradation::HostReplayedIndirectCommands`). Each draws as this
/// encoder's `draw_primitives`, `draw_indexed_primitives` or `draw_patches` would, with the
/// encoder's state as it is now, and its own pipeline state and buffers, or the encoder's
/// where `icb` inherits them (the module docs).
/// The encoder's draws before run before them and its draws after run after them.
///
/// Refused, changing nothing (`Invalid`): a buffer of another device, a range that ends past
/// its size (`IndirectCommandBufferProblem::Range`), and, for a range that is not empty, an
/// inherited pipeline state that is unset (`NoPipelineState`), at which Metal's process ends.
/// For a range that is not empty, an inherited state made without
/// `supportIndirectCommandBuffers` faults Metal's GPU at the encoder: the call is taken, the
/// encoder runs nothing, not even its load, clear or store actions, and the command buffer
/// completes with [`CommandBufferError::PageFault`](crate::CommandBufferError::PageFault), the
/// other encoders run and every event signal fires. A buffer of no command types, or of
/// dispatches beside draws of primitives, runs nothing, as plain Metal's; one of dispatches
/// alone, or beside other draws (unmeasured in a pass), is
/// `NotImplemented(IndirectRenderCommands)`. An empty range runs nothing, whatever the
/// encoder's pipeline state, as plain Metal's. What a command's draw would be
/// refused refuses the commit ([`CommandBuffer::commit`]). Where a visibility result mode is
/// set, the commands' draws count in it (the module docs).
pub fn execute_commands_in_buffer(
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::execute_commands_in_buffer`].
pub(crate) fn execute_commands_in_buffer(
&mut self,
icb: &IndirectCommandBuffer,
range: Range<u64>,
@@ -369,18 +348,8 @@ impl RenderCommandEncoder {
self.execute_range(icb, range, None)
}
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) with a check of the
/// commands its host step runs (a runtime extension; Metal has none), which looks for `needs`:
/// where a host step records the pass from the records as the GPU and the CPU left them (an
/// encoder made `icb` resident for writing, `IndirectCommandBuffer::gpu_written`), the step
/// first calls `check` with each command of the range it will record, in order, before it
/// records any of them ([`IndirectCommandCheck`]). An execution `commit` records from the CPU's
/// records never calls it; nor does one that runs on the GPU alone (`render/executions/gpu.rs`),
/// which it may only where what `icb`'s records may hold, at the commit and again as the
/// pass's batch is ready to submit, rules out every kind `needs` names
/// ([`IndirectCommandCheckNeeds`], [`IndirectCommandCheckNeeds::ALL`] included). Refused as
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) refuses.
pub fn execute_commands_in_buffer_checked(
/// The lowering of [`RenderCommandEncoder::execute_commands_in_buffer_checked`].
pub(crate) fn execute_commands_in_buffer_checked(
&mut self,
icb: &IndirectCommandBuffer,
range: Range<u64>,
@@ -424,31 +393,8 @@ impl RenderCommandEncoder {
self.defer_execution(icb, ExecutionRange::Fixed(range), pipeline, check)
}
/// `executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:`: run the render commands
/// of `icb` that the `MTLIndirectCommandBufferExecutionRange` at `offset` of `range_buffer`
/// (`location`, then `length`, each a `u32`) names as the execution runs, as
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) runs a range given. The
/// range is taken as Metal's execution takes it (a probe, an M3 Max and an M4): from the
/// location, clamped at the buffer's size, so a length of 0 or a location at the size runs
/// nothing and a length past it runs to its end; a location past the size, or a range past
/// `2^32 - 1`, at which Metal's GPU faults the command buffer, runs nothing, and the command
/// buffer's execution report states `ReplayFaults::RANGE`. The encoder copies the range where
/// it is encoded, behind a barrier from everything before, so the range a kernel of an earlier
/// encoder wrote is read; a host step records the pass once the work before it completed, which
/// the device announces once (`Degradation::HostReplayedIndirectCommands`).
///
/// Refused, changing nothing: what
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) refuses but a range (an
/// unset inherited state whatever the range); a range buffer of another device, and a range
/// Metal's reading of is not defined (`Invalid`, `IndirectCommandBufferProblem::RangeBuffer`):
/// an offset that is not a multiple of 4 bytes, at which Metal's GPU faulted, or 8 bytes that
/// run past `range_buffer`, which Metal reads from whatever follows it. A range a draw of the
/// encoder before the call may write is `NotImplemented(IndirectRenderCommands)`: Metal's
/// execution reads that draw's write, where the runtime's copy, made before the pass, would
/// not; as for the index bounds pass, an untracked buffer's writes are not seen. Under an
/// inherited state made without `supportIndirectCommandBuffers`, whatever the range, `{0, 0}`
/// included, the encoder faults as `execute_commands_in_buffer`'s does.
pub fn execute_commands_in_buffer_indirect(
/// The lowering of [`RenderCommandEncoder::execute_commands_in_buffer_indirect`].
pub(crate) fn execute_commands_in_buffer_indirect(
&mut self,
icb: &IndirectCommandBuffer,
range_buffer: &Buffer,
@@ -457,14 +403,8 @@ impl RenderCommandEncoder {
self.execute_indirect_range(icb, range_buffer, offset, None)
}
/// [`execute_commands_in_buffer_indirect`](Self::execute_commands_in_buffer_indirect) with a
/// check of the commands its host step runs, which always records the pass: the step first
/// calls `check` with each command of the range it read that it will record, in order, before
/// it records any of them, as
/// [`execute_commands_in_buffer_checked`](Self::execute_commands_in_buffer_checked)'s does
/// ([`IndirectCommandCheck`]). Refused as
/// [`execute_commands_in_buffer_indirect`](Self::execute_commands_in_buffer_indirect) refuses.
pub fn execute_commands_in_buffer_indirect_checked(
/// The lowering of [`RenderCommandEncoder::execute_commands_in_buffer_indirect_checked`].
pub(crate) fn execute_commands_in_buffer_indirect_checked(
&mut self,
icb: &IndirectCommandBuffer,
range_buffer: &Buffer,
@@ -791,6 +731,113 @@ impl RenderCommandEncoder {
}
}
impl RenderCommandEncoder {
/// `executeCommandsInBuffer:withRange:`: run render commands `range` of `icb` here, as their
/// records stand when the command buffer is committed, or, where an encoder made `icb`
/// resident for writing, once the work before them completed (a host step the device
/// announces once, `Degradation::HostReplayedIndirectCommands`). Each draws as this
/// encoder's `draw_primitives`, `draw_indexed_primitives` or `draw_patches` would, with the
/// encoder's state as it is now, and its own pipeline state and buffers, or the encoder's
/// where `icb` inherits them (the module docs).
/// The encoder's draws before run before them and its draws after run after them.
///
/// Refused, changing nothing (`Invalid`): a buffer of another device, a range that ends past
/// its size (`IndirectCommandBufferProblem::Range`), and, for a range that is not empty, an
/// inherited pipeline state that is unset (`NoPipelineState`), at which Metal's process ends.
/// For a range that is not empty, an inherited state made without
/// `supportIndirectCommandBuffers` faults Metal's GPU at the encoder: the call is taken, the
/// encoder runs nothing, not even its load, clear or store actions, and the command buffer
/// completes with [`CommandBufferError::PageFault`](crate::CommandBufferError::PageFault), the
/// other encoders run and every event signal fires. A buffer of no command types, or of
/// dispatches beside draws of primitives, runs nothing, as plain Metal's; one of dispatches
/// alone, or beside other draws (unmeasured in a pass), is
/// `NotImplemented(IndirectRenderCommands)`. An empty range runs nothing, whatever the
/// encoder's pipeline state, as plain Metal's. What a command's draw would be
/// refused refuses the commit ([`CommandBuffer::commit`]). Where a visibility result mode is
/// set, the commands' draws count in it (the module docs).
pub fn execute_commands_in_buffer(
&mut self,
icb: &IndirectCommandBuffer,
range: Range<u64>,
) -> Result<(), Error> {
self.lowering.execute_commands_in_buffer(icb, range)
}
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) with a check of the
/// commands its host step runs (a runtime extension; Metal has none), which looks for `needs`:
/// where a host step records the pass from the records as the GPU and the CPU left them (an
/// encoder made `icb` resident for writing, `IndirectCommandBuffer::gpu_written`), the step
/// first calls `check` with each command of the range it will record, in order, before it
/// records any of them ([`IndirectCommandCheck`]). An execution `commit` records from the CPU's
/// records never calls it; nor does one that runs on the GPU alone (`render/executions/gpu.rs`),
/// which it may only where what `icb`'s records may hold, at the commit and again as the
/// pass's batch is ready to submit, rules out every kind `needs` names
/// ([`IndirectCommandCheckNeeds`], [`IndirectCommandCheckNeeds::ALL`] included). Refused as
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) refuses.
pub fn execute_commands_in_buffer_checked(
&mut self,
icb: &IndirectCommandBuffer,
range: Range<u64>,
check: IndirectCommandCheck,
needs: IndirectCommandCheckNeeds,
) -> Result<(), Error> {
self.lowering
.execute_commands_in_buffer_checked(icb, range, check, needs)
}
/// `executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:`: run the render commands
/// of `icb` that the `MTLIndirectCommandBufferExecutionRange` at `offset` of `range_buffer`
/// (`location`, then `length`, each a `u32`) names as the execution runs, as
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) runs a range given. The
/// range is taken as Metal's execution takes it (a probe, an M3 Max and an M4): from the
/// location, clamped at the buffer's size, so a length of 0 or a location at the size runs
/// nothing and a length past it runs to its end; a location past the size, or a range past
/// `2^32 - 1`, at which Metal's GPU faults the command buffer, runs nothing, and the command
/// buffer's execution report states `ReplayFaults::RANGE`. The encoder copies the range where
/// it is encoded, behind a barrier from everything before, so the range a kernel of an earlier
/// encoder wrote is read; a host step records the pass once the work before it completed, which
/// the device announces once (`Degradation::HostReplayedIndirectCommands`).
///
/// Refused, changing nothing: what
/// [`execute_commands_in_buffer`](Self::execute_commands_in_buffer) refuses but a range (an
/// unset inherited state whatever the range); a range buffer of another device, and a range
/// Metal's reading of is not defined (`Invalid`, `IndirectCommandBufferProblem::RangeBuffer`):
/// an offset that is not a multiple of 4 bytes, at which Metal's GPU faulted, or 8 bytes that
/// run past `range_buffer`, which Metal reads from whatever follows it. A range a draw of the
/// encoder before the call may write is `NotImplemented(IndirectRenderCommands)`: Metal's
/// execution reads that draw's write, where the runtime's copy, made before the pass, would
/// not; as for the index bounds pass, an untracked buffer's writes are not seen. Under an
/// inherited state made without `supportIndirectCommandBuffers`, whatever the range, `{0, 0}`
/// included, the encoder faults as `execute_commands_in_buffer`'s does.
pub fn execute_commands_in_buffer_indirect(
&mut self,
icb: &IndirectCommandBuffer,
range_buffer: &Buffer,
offset: u64,
) -> Result<(), Error> {
self.lowering
.execute_commands_in_buffer_indirect(icb, range_buffer, offset)
}
/// [`execute_commands_in_buffer_indirect`](Self::execute_commands_in_buffer_indirect) with a
/// check of the commands its host step runs, which always records the pass: the step first
/// calls `check` with each command of the range it read that it will record, in order, before
/// it records any of them, as
/// [`execute_commands_in_buffer_checked`](Self::execute_commands_in_buffer_checked)'s does
/// ([`IndirectCommandCheck`]). Refused as
/// [`execute_commands_in_buffer_indirect`](Self::execute_commands_in_buffer_indirect) refuses.
pub fn execute_commands_in_buffer_indirect_checked(
&mut self,
icb: &IndirectCommandBuffer,
range_buffer: &Buffer,
offset: u64,
check: IndirectCommandCheck,
) -> Result<(), Error> {
self.lowering
.execute_commands_in_buffer_indirect_checked(icb, range_buffer, offset, check)
}
}
/// Announce, once per device, an execution of commands `range` of `icb` after one in the same
/// encoder from the same command with length `earlier`, another: Metal's executions then do not
/// each run their own range, and not the same way from run to run (the module docs); the
@@ -1642,7 +1689,7 @@ fn reads_vertex_stride(pipeline: &RenderPipelineState, index: u32) -> bool {
/// it. The command buffer holds them until it completes.
pub(crate) type SettledDraw = (Arc<RenderVariant>, Option<Arc<RawPipeline>>);
impl RenderCommandEncoder {
impl RenderLowering {
/// Make, into `made`, what a command's draw of `pipeline` under the encoder's state (an
/// execution's at its call, `RenderExecution::settle`) compiles at the host step: for each
/// primitive type its input primitive topology class holds (every type for the unspecified
@@ -2040,7 +2087,7 @@ impl RenderExecution {
/// commands ran as several, and each run's steps.
fn finish(
&self,
mut encoder: RenderCommandEncoder,
mut encoder: RenderLowering,
found: &mut Found,
rendered: &mut Rendered,
device: &Device,
@@ -2051,7 +2098,7 @@ impl RenderExecution {
// left begins and ends there, empty.
encoder.visibility.end(raw, encoder.current.draws);
encoder.visibility.close_spares(raw, encoder.current.draws);
let RenderCommandEncoder {
let RenderLowering {
core,
earlier,
current,
@@ -2147,12 +2194,12 @@ impl RenderExecution {
(draws, visibility): (vk::CommandBuffer, Visibility),
(storage, layout, residency): (PassStorage, PassLayout, &Residency),
forms: BufferForms,
) -> RenderCommandEncoder {
) -> RenderLowering {
let snapshot = &self.snapshot;
// The draws use only the shadowed textures the call gathered.
let mut shadows = InstanceShadows::default();
shadows.add(&self.shadows, &[]);
RenderCommandEncoder {
RenderLowering {
core,
earlier: Vec::new(),
current: Instance {
@@ -2316,7 +2363,7 @@ impl RenderExecution {
for pipeline in named {
encoder.settle_draws(pipeline, made);
}
let RenderCommandEncoder { core, .. } = encoder;
let RenderLowering { core, .. } = encoder;
core
}
@@ -74,7 +74,7 @@ use std::sync::Arc;
use super::super::bound::{Bound, Recorded};
use super::super::pass_start_reads::PassStartTables;
use super::super::{Assembly, DrawBuffers, Recording, RenderCommandEncoder};
use super::super::{Assembly, DrawBuffers, Recording, RenderLowering};
use super::{HostStepCause, PassStorage, RenderExecution, Rendered, CALL};
use crate::binding::PushWrite;
use crate::blit::{reads_by, writes_by};
@@ -351,7 +351,7 @@ impl RenderExecution {
encoder.pipeline = Some(pipeline.clone());
encoder.replay_draw_of(state, primitive_type)
});
let RenderCommandEncoder { core, .. } = encoder;
let RenderLowering { core, .. } = encoder;
let form = match slots {
Ok(Ok(slots)) => {
let commands = (decided, primitive_type, range);
@@ -485,7 +485,7 @@ impl RenderExecution {
(command_buffer, residency): (&CommandBuffer, &Residency),
form: &GpuForm,
(storage, rendered): (PassStorage, &mut Rendered),
) -> Result<RenderCommandEncoder, Error> {
) -> Result<RenderLowering, Error> {
let snapshot = &self.snapshot;
let device = command_buffer.device().clone();
let pipeline = (self.pipeline.as_ref())
@@ -689,7 +689,7 @@ fn scratch_head(pre: &DrawReplayPreprocess, sink: u64) -> Result<Vec<u8>, Error>
Ok(bytes)
}
impl RenderCommandEncoder {
impl RenderLowering {
/// The buffer slots the vertex and fragment functions of a command's draw of `state` as
/// `primitive_type` read, through this encoder (an execution's at its call, in the replay
/// form or the merged one, its `forms`), where that draw records as the GPU form's draws do
@@ -38,7 +38,7 @@
//! so `extended-range-blends-stored-codes` names only the colors a draw read from the codes
//! (`degrade_extended_range_blends`, `ExtendedShadows::held`).
use super::RenderCommandEncoder;
use super::RenderLowering;
use crate::blit::TRANSFER;
use crate::command_buffer::CommandBuffer;
use crate::device::functions::Vk;
@@ -411,7 +411,7 @@ fn color(
.and_then(Option::as_ref)
}
impl RenderCommandEncoder {
impl RenderLowering {
/// The shadows a draw binds: the held ones, none while the encoder records an execution's
/// commands or a capture draw.
pub(super) fn extended_shadows_bound(&self) -> &BTreeSet<u32> {
@@ -129,7 +129,7 @@
use super::extended_shadow::ExtendedShadows;
use super::inline_splits::Later;
use super::{Instance, Next, RenderCommandEncoder, ViewSetup};
use super::{Instance, Next, RenderLowering, ViewSetup};
use crate::clear_reach;
use crate::device::Device;
use crate::error::Error;
@@ -298,7 +298,7 @@ fn inline_area(layout: &PassLayout) -> [u32; 2] {
}
}
impl RenderCommandEncoder {
impl RenderLowering {
/// Begin the current instance's secondary where the pass left it unbegun (`Instance::draws`):
/// a pass that may record its first instance inline begins none at its opening, and one only
/// where a command records into that instance's secondary or a split keeps the instance. An
@@ -73,9 +73,7 @@
use super::bound::{Bound, Recorded};
use super::pending::OwnedRecording;
use super::{
inline_first, shadows, Clears, Instance, Next, Recording, RenderCommandEncoder, ViewSetup,
};
use super::{inline_first, shadows, Clears, Instance, Next, Recording, RenderLowering, ViewSetup};
use crate::attachment_stand_in::Cause;
use crate::clear_reach;
use crate::color_list::ColorList;
@@ -242,7 +240,7 @@ pub(super) struct SplitBegin {
clears: Option<Clears>,
}
impl RenderCommandEncoder {
impl RenderLowering {
/// Whether the draw about to record into `next` begins a new instance that records inline
/// after the current one (the module docs; `records`: the draw records, `made` its pipeline,
/// `capture` a capture draw, `stood` a stand-in arriving with it); where it does, the current
@@ -31,6 +31,7 @@
use super::RenderCall;
use super::RenderCommandEncoder;
use super::RenderLowering;
use crate::argument_table::check_index;
use crate::command_buffer::CommandBuffer;
use crate::error::{invalid, Error, Problem};
@@ -95,12 +96,9 @@ fn wanted(target: Option<&ResolveTarget>, store: StoreAction) -> Wanted<'_> {
}
}
impl RenderCommandEncoder {
/// The color attachment at `index` resolves into `target` (`None`: nowhere), whatever the
/// descriptor named (the module docs). Refused (`Invalid`): an index past the attachments,
/// an attachment without a texture, and a target the descriptor's resolve texture would be
/// refused as (Metal's validation stops another pixel format or size, measured).
pub fn set_color_resolve_target(
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::set_color_resolve_target`].
pub(crate) fn set_color_resolve_target(
&mut self,
target: Option<ResolveTarget>,
index: u32,
@@ -152,18 +150,17 @@ impl RenderCommandEncoder {
Ok(())
}
/// The depth attachment resolves into `target` (`None`: nowhere), whatever the descriptor
/// named. Refused as [`RenderCommandEncoder::set_color_resolve_target`] is, and as the
/// descriptor's depth resolve is where the stencil attachment is the same texture (both
/// aspects into one texture, the stencil stored while the depth resolves).
pub fn set_depth_resolve_target(&mut self, target: Option<ResolveTarget>) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_depth_resolve_target`].
pub(crate) fn set_depth_resolve_target(
&mut self,
target: Option<ResolveTarget>,
) -> Result<(), Error> {
self.log(|_| RenderCall::DepthResolveTarget(target.clone().map(Box::new)));
self.set_aspect_resolve_target("set_depth_resolve_target", Attachment::Depth, target)
}
/// The stencil attachment resolves into `target` (`None`: nowhere). Refused as
/// [`RenderCommandEncoder::set_depth_resolve_target`] is, the aspects swapped.
pub fn set_stencil_resolve_target(
/// The lowering of [`RenderCommandEncoder::set_stencil_resolve_target`].
pub(crate) fn set_stencil_resolve_target(
&mut self,
target: Option<ResolveTarget>,
) -> Result<(), Error> {
@@ -239,6 +236,37 @@ impl RenderCommandEncoder {
}
}
impl RenderCommandEncoder {
/// The color attachment at `index` resolves into `target` (`None`: nowhere), whatever the
/// descriptor named (the module docs). Refused (`Invalid`): an index past the attachments,
/// an attachment without a texture, and a target the descriptor's resolve texture would be
/// refused as (Metal's validation stops another pixel format or size, measured).
pub fn set_color_resolve_target(
&mut self,
target: Option<ResolveTarget>,
index: u32,
) -> Result<(), Error> {
self.lowering.set_color_resolve_target(target, index)
}
/// The depth attachment resolves into `target` (`None`: nowhere), whatever the descriptor
/// named. Refused as [`RenderCommandEncoder::set_color_resolve_target`] is, and as the
/// descriptor's depth resolve is where the stencil attachment is the same texture (both
/// aspects into one texture, the stencil stored while the depth resolves).
pub fn set_depth_resolve_target(&mut self, target: Option<ResolveTarget>) -> Result<(), Error> {
self.lowering.set_depth_resolve_target(target)
}
/// The stencil attachment resolves into `target` (`None`: nowhere). Refused as
/// [`RenderCommandEncoder::set_depth_resolve_target`] is, the aspects swapped.
pub fn set_stencil_resolve_target(
&mut self,
target: Option<ResolveTarget>,
) -> Result<(), Error> {
self.lowering.set_stencil_resolve_target(target)
}
}
fn problem(call: &'static str, p: RenderPassProblem) -> Error {
invalid(call, Problem::RenderPass(p))
}
+273 -79
View File
@@ -73,6 +73,7 @@
use super::replay::Samplers;
use super::RenderCommandEncoder;
use super::RenderLowering;
use super::{check_arguments, draw_problem, Assembly, DrawBuffers, DrawProblem};
use super::{RenderCall, Table};
use crate::binding::{MeshRegions, PushWrite};
@@ -123,10 +124,9 @@ const METAL_THREADGROUP_THREADS: u64 = 1024;
/// `VkDrawMeshTasksIndirectCommandEXT`'s.
const INDIRECT_BYTES: u64 = 12;
impl RenderCommandEncoder {
/// `setObjectBuffer:offset:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_buffer`](Self::set_vertex_buffer) is.
pub fn set_object_buffer(
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::set_object_buffer`].
pub(crate) fn set_object_buffer(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
@@ -140,9 +140,8 @@ impl RenderCommandEncoder {
.set_buffer(&mut self.core, "set_object_buffer", buffer, offset, index)
}
/// `setObjectBuffers:offsets:withRange:`. Refused as
/// [`set_vertex_buffers`](Self::set_vertex_buffers) is.
pub fn set_object_buffers(
/// The lowering of [`RenderCommandEncoder::set_object_buffers`].
pub(crate) fn set_object_buffers(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
@@ -165,25 +164,26 @@ impl RenderCommandEncoder {
)
}
/// `setObjectBufferOffset:atIndex:`. Refused as
/// [`set_vertex_buffer_offset`](Self::set_vertex_buffer_offset) is.
pub fn set_object_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_object_buffer_offset`].
pub(crate) fn set_object_buffer_offset(
&mut self,
offset: u64,
index: u32,
) -> Result<(), Error> {
self.log(|_| RenderCall::BufferOffset(Table::Object, offset, index));
self.object
.set_buffer_offset(&mut self.core, "set_object_buffer_offset", offset, index)
}
/// `setObjectBytes:length:atIndex:`: as [`set_vertex_bytes`](Self::set_vertex_bytes), in
/// the object stage's table. Refused as that is.
pub fn set_object_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_object_bytes`].
pub(crate) fn set_object_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
self.log(|log| RenderCall::Bytes(Table::Object, log.byte_span(bytes), index));
self.object
.set_bytes(&mut self.core, "set_object_bytes", bytes, None, index)
}
/// `setObjectTexture:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_texture`](Self::set_vertex_texture) is.
pub fn set_object_texture(
/// The lowering of [`RenderCommandEncoder::set_object_texture`].
pub(crate) fn set_object_texture(
&mut self,
texture: Option<&Texture>,
index: u32,
@@ -196,9 +196,8 @@ impl RenderCommandEncoder {
.set_textures(&mut self.core, "set_object_texture", &[texture], index)
}
/// `setObjectTextures:withRange:`. Refused as
/// [`set_vertex_textures`](Self::set_vertex_textures) is.
pub fn set_object_textures(
/// The lowering of [`RenderCommandEncoder::set_object_textures`].
pub(crate) fn set_object_textures(
&mut self,
textures: &[Option<&Texture>],
first: u32,
@@ -208,9 +207,8 @@ impl RenderCommandEncoder {
.set_textures(&mut self.core, "set_object_textures", textures, first)
}
/// `setObjectSamplerState:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_sampler_state`](Self::set_vertex_sampler_state) is.
pub fn set_object_sampler_state(
/// The lowering of [`RenderCommandEncoder::set_object_sampler_state`].
pub(crate) fn set_object_sampler_state(
&mut self,
sampler: Option<&SamplerState>,
index: u32,
@@ -228,10 +226,8 @@ impl RenderCommandEncoder {
)
}
/// `setObjectSamplerStates:withRange:`, or with `clamps`
/// `setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange:`. Refused as
/// [`set_vertex_sampler_states`](Self::set_vertex_sampler_states) is.
pub fn set_object_sampler_states(
/// The lowering of [`RenderCommandEncoder::set_object_sampler_states`].
pub(crate) fn set_object_sampler_states(
&mut self,
samplers: &[Option<&SamplerState>],
clamps: Option<(&[f32], &[f32])>,
@@ -247,17 +243,8 @@ impl RenderCommandEncoder {
)
}
/// `setObjectThreadgroupMemoryLength:atIndex:`: the length of the object function's
/// `[[threadgroup(index)]]` argument in the encoder's later mesh draws, whichever pipeline
/// state they use; until it is set an argument's length is 0. A length that is not a multiple
/// of 16 bytes is rounded up to 16 at the draw, as a kernel's
/// (`ComputeCommandEncoder::set_threadgroup_memory_length`) is. Refused: an index past the
/// table (`Invalid`). The object function's arena with these lengths must fit the device's
/// workgroup memory for the object stage, checked at the draw
/// (`Unsupported{ThreadgroupMemorySize}` naming the limit). An indirect command's mesh draw
/// takes none of these: one whose object function reads them is
/// `NotImplemented(IndirectRenderCommands)`.
pub fn set_object_threadgroup_memory_length(
/// The lowering of [`RenderCommandEncoder::set_object_threadgroup_memory_length`].
pub(crate) fn set_object_threadgroup_memory_length(
&mut self,
length: u32,
index: u32,
@@ -269,9 +256,8 @@ impl RenderCommandEncoder {
Ok(())
}
/// `setMeshBuffer:offset:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_buffer`](Self::set_vertex_buffer) is.
pub fn set_mesh_buffer(
/// The lowering of [`RenderCommandEncoder::set_mesh_buffer`].
pub(crate) fn set_mesh_buffer(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
@@ -285,9 +271,8 @@ impl RenderCommandEncoder {
.set_buffer(&mut self.core, "set_mesh_buffer", buffer, offset, index)
}
/// `setMeshBuffers:offsets:withRange:`. Refused as
/// [`set_vertex_buffers`](Self::set_vertex_buffers) is.
pub fn set_mesh_buffers(
/// The lowering of [`RenderCommandEncoder::set_mesh_buffers`].
pub(crate) fn set_mesh_buffers(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
@@ -305,25 +290,26 @@ impl RenderCommandEncoder {
.set_buffers(&mut self.core, "set_mesh_buffers", buffers, offsets, first)
}
/// `setMeshBufferOffset:atIndex:`. Refused as
/// [`set_vertex_buffer_offset`](Self::set_vertex_buffer_offset) is.
pub fn set_mesh_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_mesh_buffer_offset`].
pub(crate) fn set_mesh_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
self.log(|_| RenderCall::BufferOffset(Table::Mesh, offset, index));
self.mesh
.set_buffer_offset(&mut self.core, "set_mesh_buffer_offset", offset, index)
}
/// `setMeshBytes:length:atIndex:`: as [`set_vertex_bytes`](Self::set_vertex_bytes), in the
/// mesh stage's table. Refused as that is.
pub fn set_mesh_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_mesh_bytes`].
pub(crate) fn set_mesh_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
self.log(|log| RenderCall::Bytes(Table::Mesh, log.byte_span(bytes), index));
self.mesh
.set_bytes(&mut self.core, "set_mesh_bytes", bytes, None, index)
}
/// `setMeshTexture:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_texture`](Self::set_vertex_texture) is.
pub fn set_mesh_texture(&mut self, texture: Option<&Texture>, index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_mesh_texture`].
pub(crate) fn set_mesh_texture(
&mut self,
texture: Option<&Texture>,
index: u32,
) -> Result<(), Error> {
self.log(|log| {
let texture = texture.map(|texture| log.hold_texture(texture));
RenderCall::Texture(Table::Mesh, texture, index)
@@ -332,9 +318,8 @@ impl RenderCommandEncoder {
.set_textures(&mut self.core, "set_mesh_texture", &[texture], index)
}
/// `setMeshTextures:withRange:`. Refused as
/// [`set_vertex_textures`](Self::set_vertex_textures) is.
pub fn set_mesh_textures(
/// The lowering of [`RenderCommandEncoder::set_mesh_textures`].
pub(crate) fn set_mesh_textures(
&mut self,
textures: &[Option<&Texture>],
first: u32,
@@ -344,9 +329,8 @@ impl RenderCommandEncoder {
.set_textures(&mut self.core, "set_mesh_textures", textures, first)
}
/// `setMeshSamplerState:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_sampler_state`](Self::set_vertex_sampler_state) is.
pub fn set_mesh_sampler_state(
/// The lowering of [`RenderCommandEncoder::set_mesh_sampler_state`].
pub(crate) fn set_mesh_sampler_state(
&mut self,
sampler: Option<&SamplerState>,
index: u32,
@@ -364,10 +348,8 @@ impl RenderCommandEncoder {
)
}
/// `setMeshSamplerStates:withRange:`, or with `clamps`
/// `setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:`. Refused as
/// [`set_vertex_sampler_states`](Self::set_vertex_sampler_states) is.
pub fn set_mesh_sampler_states(
/// The lowering of [`RenderCommandEncoder::set_mesh_sampler_states`].
pub(crate) fn set_mesh_sampler_states(
&mut self,
samplers: &[Option<&SamplerState>],
clamps: Option<(&[f32], &[f32])>,
@@ -383,10 +365,8 @@ impl RenderCommandEncoder {
)
}
/// `drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:`: `groups`
/// mesh threadgroups of `threads_per_mesh_group` threads (the module docs). Refused as the
/// module docs say, and for a size past 32 bits on an axis (`Invalid(SizeOutOfRange)`).
pub fn draw_mesh_threadgroups(
/// The lowering of [`RenderCommandEncoder::draw_mesh_threadgroups`].
pub(crate) fn draw_mesh_threadgroups(
&mut self,
groups: Size,
threads_per_object_group: Size,
@@ -406,10 +386,8 @@ impl RenderCommandEncoder {
self.draw_mesh(CALL, grid, object, mesh)
}
/// `drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:`: the whole mesh
/// threadgroups of `threads_per_mesh_group` threads that `threads` fill (the module docs).
/// Refused as [`draw_mesh_threadgroups`](Self::draw_mesh_threadgroups) is.
pub fn draw_mesh_threads(
/// The lowering of [`RenderCommandEncoder::draw_mesh_threads`].
pub(crate) fn draw_mesh_threads(
&mut self,
threads: Size,
threads_per_object_group: Size,
@@ -462,15 +440,8 @@ impl RenderCommandEncoder {
self.draw(call, Assembly::Meshes, draw, DrawBuffers::default(), empty)
}
/// `drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:
/// threadsPerMeshThreadgroup:`: Metal's `MTLDispatchThreadgroupsIndirectArguments` at
/// `indirect_buffer_offset`, the threadgroups' counts. Refused as
/// [`draw_mesh_threadgroups`](Self::draw_mesh_threadgroups) is, as an indirect draw's
/// arguments are (`render.rs`'s module docs), and for an indirect buffer of another device.
/// On a device with `VK_EXT_mesh_shader` the draw is `NotImplemented(IndirectDrawArguments)`,
/// and on one without it, of a pipeline with an object function, `NotImplemented(MeshShading)`
/// (the module docs).
pub fn draw_mesh_threadgroups_indirect(
/// The lowering of [`RenderCommandEncoder::draw_mesh_threadgroups_indirect`].
pub(crate) fn draw_mesh_threadgroups_indirect(
&mut self,
indirect_buffer: &Buffer,
indirect_buffer_offset: u64,
@@ -567,6 +538,229 @@ impl RenderCommandEncoder {
}
}
impl RenderCommandEncoder {
/// `setObjectBuffer:offset:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_buffer`](Self::set_vertex_buffer) is.
pub fn set_object_buffer(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
index: u32,
) -> Result<(), Error> {
self.lowering.set_object_buffer(buffer, offset, index)
}
/// `setObjectBuffers:offsets:withRange:`. Refused as
/// [`set_vertex_buffers`](Self::set_vertex_buffers) is.
pub fn set_object_buffers(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
first: u32,
) -> Result<(), Error> {
self.lowering.set_object_buffers(buffers, offsets, first)
}
/// `setObjectBufferOffset:atIndex:`. Refused as
/// [`set_vertex_buffer_offset`](Self::set_vertex_buffer_offset) is.
pub fn set_object_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
self.lowering.set_object_buffer_offset(offset, index)
}
/// `setObjectBytes:length:atIndex:`: as [`set_vertex_bytes`](Self::set_vertex_bytes), in
/// the object stage's table. Refused as that is.
pub fn set_object_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
self.lowering.set_object_bytes(bytes, index)
}
/// `setObjectTexture:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_texture`](Self::set_vertex_texture) is.
pub fn set_object_texture(
&mut self,
texture: Option<&Texture>,
index: u32,
) -> Result<(), Error> {
self.lowering.set_object_texture(texture, index)
}
/// `setObjectTextures:withRange:`. Refused as
/// [`set_vertex_textures`](Self::set_vertex_textures) is.
pub fn set_object_textures(
&mut self,
textures: &[Option<&Texture>],
first: u32,
) -> Result<(), Error> {
self.lowering.set_object_textures(textures, first)
}
/// `setObjectSamplerState:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_sampler_state`](Self::set_vertex_sampler_state) is.
pub fn set_object_sampler_state(
&mut self,
sampler: Option<&SamplerState>,
index: u32,
) -> Result<(), Error> {
self.lowering.set_object_sampler_state(sampler, index)
}
/// `setObjectSamplerStates:withRange:`, or with `clamps`
/// `setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange:`. Refused as
/// [`set_vertex_sampler_states`](Self::set_vertex_sampler_states) is.
pub fn set_object_sampler_states(
&mut self,
samplers: &[Option<&SamplerState>],
clamps: Option<(&[f32], &[f32])>,
first: u32,
) -> Result<(), Error> {
self.lowering
.set_object_sampler_states(samplers, clamps, first)
}
/// `setObjectThreadgroupMemoryLength:atIndex:`: the length of the object function's
/// `[[threadgroup(index)]]` argument in the encoder's later mesh draws, whichever pipeline
/// state they use; until it is set an argument's length is 0. A length that is not a multiple
/// of 16 bytes is rounded up to 16 at the draw, as a kernel's
/// (`ComputeCommandEncoder::set_threadgroup_memory_length`) is. Refused: an index past the
/// table (`Invalid`). The object function's arena with these lengths must fit the device's
/// workgroup memory for the object stage, checked at the draw
/// (`Unsupported{ThreadgroupMemorySize}` naming the limit). An indirect command's mesh draw
/// takes none of these: one whose object function reads them is
/// `NotImplemented(IndirectRenderCommands)`.
pub fn set_object_threadgroup_memory_length(
&mut self,
length: u32,
index: u32,
) -> Result<(), Error> {
self.lowering
.set_object_threadgroup_memory_length(length, index)
}
/// `setMeshBuffer:offset:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_buffer`](Self::set_vertex_buffer) is.
pub fn set_mesh_buffer(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
index: u32,
) -> Result<(), Error> {
self.lowering.set_mesh_buffer(buffer, offset, index)
}
/// `setMeshBuffers:offsets:withRange:`. Refused as
/// [`set_vertex_buffers`](Self::set_vertex_buffers) is.
pub fn set_mesh_buffers(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
first: u32,
) -> Result<(), Error> {
self.lowering.set_mesh_buffers(buffers, offsets, first)
}
/// `setMeshBufferOffset:atIndex:`. Refused as
/// [`set_vertex_buffer_offset`](Self::set_vertex_buffer_offset) is.
pub fn set_mesh_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
self.lowering.set_mesh_buffer_offset(offset, index)
}
/// `setMeshBytes:length:atIndex:`: as [`set_vertex_bytes`](Self::set_vertex_bytes), in the
/// mesh stage's table. Refused as that is.
pub fn set_mesh_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
self.lowering.set_mesh_bytes(bytes, index)
}
/// `setMeshTexture:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_texture`](Self::set_vertex_texture) is.
pub fn set_mesh_texture(&mut self, texture: Option<&Texture>, index: u32) -> Result<(), Error> {
self.lowering.set_mesh_texture(texture, index)
}
/// `setMeshTextures:withRange:`. Refused as
/// [`set_vertex_textures`](Self::set_vertex_textures) is.
pub fn set_mesh_textures(
&mut self,
textures: &[Option<&Texture>],
first: u32,
) -> Result<(), Error> {
self.lowering.set_mesh_textures(textures, first)
}
/// `setMeshSamplerState:atIndex:` (`None` unbinds the index). Refused as
/// [`set_vertex_sampler_state`](Self::set_vertex_sampler_state) is.
pub fn set_mesh_sampler_state(
&mut self,
sampler: Option<&SamplerState>,
index: u32,
) -> Result<(), Error> {
self.lowering.set_mesh_sampler_state(sampler, index)
}
/// `setMeshSamplerStates:withRange:`, or with `clamps`
/// `setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:`. Refused as
/// [`set_vertex_sampler_states`](Self::set_vertex_sampler_states) is.
pub fn set_mesh_sampler_states(
&mut self,
samplers: &[Option<&SamplerState>],
clamps: Option<(&[f32], &[f32])>,
first: u32,
) -> Result<(), Error> {
self.lowering
.set_mesh_sampler_states(samplers, clamps, first)
}
/// `drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:`: `groups`
/// mesh threadgroups of `threads_per_mesh_group` threads (the module docs). Refused as the
/// module docs say, and for a size past 32 bits on an axis (`Invalid(SizeOutOfRange)`).
pub fn draw_mesh_threadgroups(
&mut self,
groups: Size,
threads_per_object_group: Size,
threads_per_mesh_group: Size,
) -> Result<(), Error> {
self.lowering.draw_mesh_threadgroups(
groups,
threads_per_object_group,
threads_per_mesh_group,
)
}
/// `drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:`: the whole mesh
/// threadgroups of `threads_per_mesh_group` threads that `threads` fill (the module docs).
/// Refused as [`draw_mesh_threadgroups`](Self::draw_mesh_threadgroups) is.
pub fn draw_mesh_threads(
&mut self,
threads: Size,
threads_per_object_group: Size,
threads_per_mesh_group: Size,
) -> Result<(), Error> {
self.lowering
.draw_mesh_threads(threads, threads_per_object_group, threads_per_mesh_group)
}
/// `drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:
/// threadsPerMeshThreadgroup:`: Metal's `MTLDispatchThreadgroupsIndirectArguments` at
/// `indirect_buffer_offset`, the threadgroups' counts. Refused as
/// [`draw_mesh_threadgroups`](Self::draw_mesh_threadgroups) is, as an indirect draw's
/// arguments are (`render.rs`'s module docs), and for an indirect buffer of another device.
/// On a device with `VK_EXT_mesh_shader` the draw is `NotImplemented(IndirectDrawArguments)`,
/// and on one without it, of a pipeline with an object function, `NotImplemented(MeshShading)`
/// (the module docs).
pub fn draw_mesh_threadgroups_indirect(
&mut self,
indirect_buffer: &Buffer,
indirect_buffer_offset: u64,
threads_per_object_group: Size,
threads_per_mesh_group: Size,
) -> Result<(), Error> {
self.lowering.draw_mesh_threadgroups_indirect(
indirect_buffer,
indirect_buffer_offset,
threads_per_object_group,
threads_per_mesh_group,
)
}
}
/// A direct mesh draw's grid: of threadgroups (`drawMeshThreadgroups`) or of threads
/// (`drawMeshThreads`).
#[derive(Clone, Copy, Debug)]
@@ -15,7 +15,7 @@
//! buffer, where an encoding again would leave the first one's beside its own.
//! - **Per-stage calls** share a variant, with the [`Table`] they set.
use super::RenderCommandEncoder;
use super::RenderLowering;
use crate::amplification::VertexAmplificationViewMapping;
use crate::buffer::Buffer;
use crate::command_buffer::CommandBuffer;
@@ -103,7 +103,7 @@ impl RenderLog {
/// (`render/color_groups.rs`). A call refused there was refused in the first group's
/// encoder, whose answer the program had, or is a divergence the later group's encoder notes
/// (`RenderCommandEncoder::group_outcome`): either way the calls after it run.
pub(crate) fn replay_into(&self, encoder: &mut RenderCommandEncoder) {
pub(crate) fn replay_into(&self, encoder: &mut RenderLowering) {
for call in &self.calls.calls {
let _ = render(encoder, (&self.calls, &self.indexed), call);
}
@@ -115,8 +115,7 @@ impl RenderLog {
command_buffer: &CommandBuffer,
residency: Residency,
) -> Result<(Replayed, Option<Residency>), Error> {
let mut encoder =
RenderCommandEncoder::replaying(command_buffer, &self.descriptor, residency)?;
let mut encoder = RenderLowering::replaying(command_buffer, &self.descriptor, residency)?;
for call in &self.calls.calls {
render(&mut encoder, (&self.calls, &self.indexed), call)?;
}
@@ -345,7 +344,7 @@ pub(crate) struct DrawIndexedPatchesIndirect {
pub(super) indirect_buffer_offset: u64,
}
impl RenderCommandEncoder {
impl RenderLowering {
/// Log the call `call` makes of the log, before it runs, where the encoder logs (the module
/// docs).
pub(crate) fn log(&mut self, call: impl FnOnce(&mut CallLog<RenderCall>) -> RenderCall) {
@@ -376,7 +375,7 @@ impl RenderCommandEncoder {
/// Run `call` again on `encoder`, its slices in `log`'s arenas and an indexed draw's arguments in
/// `indexed`.
fn render(
encoder: &mut RenderCommandEncoder,
encoder: &mut RenderLowering,
(log, indexed): (&CallLog<RenderCall>, &[DrawIndexed]),
call: &RenderCall,
) -> Result<(), Error> {
@@ -35,7 +35,7 @@
//! view or image of its own, so a texture's storage form taking another image after the command
//! buffer commits (`texture/storage_form.rs`) changes nothing it records.
use super::{Assembly, DrawBuffers, Next, RenderCommandEncoder};
use super::{Assembly, DrawBuffers, Next, RenderLowering};
use crate::amplification::Amplification;
use crate::argument_table::ArgumentTable;
use crate::draw_source::{DrawSource, KeptSource};
@@ -94,7 +94,7 @@ struct Held {
amplification: Amplification,
}
impl RenderCommandEncoder {
impl RenderLowering {
/// Keep the draw just recorded into the current instance (`call` of `assembly` and `draw`,
/// its indices from `index`) for recording again where `again` (the module docs) and the
/// instance keeps fewer than `MAX_DRAWS`; otherwise the instance's draws record again no
@@ -22,7 +22,8 @@
//! rewrite pass writes (`index_rewrite.rs`), with the class's list topology.
use super::RenderCall;
use super::{Assembly, RenderCommandEncoder};
use super::RenderCommandEncoder;
use super::{Assembly, RenderLowering};
use metal2vulkan::bind::{DrawCall, RewriteProgram};
use metal2vulkan::metal::PrimitiveType;
@@ -45,16 +46,9 @@ impl Restarted {
}
}
impl RenderCommandEncoder {
/// `setPrimitiveRestartEnabled:index:` (SPI): the encoder's indexed line and triangle strips
/// drawn after the call restart at `index` as Metal takes it for their index type (`k mod
/// 2^32` for 32-bit indices, the lesser of that and `0xffff` for 16-bit ones), and only
/// there: the all-ones index then draws as a vertex unless it is that index. `_enabled`
/// changes nothing, as on Metal. Lists, points, draws without indices and executions of
/// indirect render commands are as before; the last call wins until the encoder ends (an M4). A
/// strip restarting elsewhere than at the all-ones index is drawn as a list a GPU pass writes
/// before the pass; a draw it cannot draw so is refused (`NotImplemented(RestartedStrip)`).
pub fn set_primitive_restart_enabled(&mut self, _enabled: bool, index: u64) {
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::set_primitive_restart_enabled`].
pub(crate) fn set_primitive_restart_enabled(&mut self, _enabled: bool, index: u64) {
self.log(|_| RenderCall::PrimitiveRestartEnabled(_enabled, index));
self.restart = Some(index);
}
@@ -87,6 +81,20 @@ impl RenderCommandEncoder {
}
}
impl RenderCommandEncoder {
/// `setPrimitiveRestartEnabled:index:` (SPI): the encoder's indexed line and triangle strips
/// drawn after the call restart at `index` as Metal takes it for their index type (`k mod
/// 2^32` for 32-bit indices, the lesser of that and `0xffff` for 16-bit ones), and only
/// there: the all-ones index then draws as a vertex unless it is that index. `_enabled`
/// changes nothing, as on Metal. Lists, points, draws without indices and executions of
/// indirect render commands are as before; the last call wins until the encoder ends (an M4). A
/// strip restarting elsewhere than at the all-ones index is drawn as a list a GPU pass writes
/// before the pass; a draw it cannot draw so is refused (`NotImplemented(RestartedStrip)`).
pub fn set_primitive_restart_enabled(&mut self, _enabled: bool, index: u64) {
self.lowering.set_primitive_restart_enabled(_enabled, index)
}
}
/// `k'` for a call with `k` over 32-bit indices (`wide`) or 16-bit ones, and the index type's
/// all-ones index.
fn restart_index(k: u64, wide: bool) -> (u32, u32) {
@@ -102,7 +102,7 @@
//! share of their colors' pixels and texel bytes, a line at 64 of them, each power of two
//! after, and as the device ends (`metal2vulkan-snapshot-readers`, `reader_sizes.rs`).
use super::{Reformat, RenderCommandEncoder};
use super::{Reformat, RenderLowering};
use crate::copy_plan::block_bytes;
use crate::dynamic_state::ColorWriteMasks;
use crate::pipeline::{GraphicsState as DrawingState, Settled};
@@ -248,7 +248,7 @@ pub(super) fn phase_hole(holes: &[PushHole]) -> Option<(vk::ShaderStageFlags, u3
})
}
impl RenderCommandEncoder {
impl RenderLowering {
/// What a draw of `pipeline` (its state's base) through `reformats` asks to read through
/// snapshots, where it can ask (the module docs' checks that come before the plan); `None`
/// where it reads no attachment so or takes the split.
@@ -97,7 +97,8 @@
use super::pending_tile::{TileCall, TilePipelines};
use super::replay::Samplers;
use super::shadows::InstanceShadows;
use super::{draw_problem, DrawProblem, RenderCommandEncoder};
use super::RenderCommandEncoder;
use super::{draw_problem, DrawProblem, RenderLowering};
use super::{RenderCall, Table};
use crate::address_map;
use crate::attachment_stand_in;
@@ -579,23 +580,19 @@ fn scratch(
})
}
impl RenderCommandEncoder {
/// `tileWidth`: the pass's tile width, or the default for its samples (32; `tile_pass.rs`).
/// Not measured (`NotImplemented(TileAtSampleCount)`) in a pass of a sample count Apple's
/// GPUs lack.
pub fn tile_width(&self) -> Result<u64, Error> {
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::tile_width`].
pub(crate) fn tile_width(&self) -> Result<u64, Error> {
self.layout.tile_size().map(|[width, _]| width.into())
}
/// `tileHeight`: the pass's tile height, or the default for its samples (32, and 16 at 4
/// samples; `tile_pass.rs`). Not measured as [`RenderCommandEncoder::tile_width`] is not.
pub fn tile_height(&self) -> Result<u64, Error> {
/// The lowering of [`RenderCommandEncoder::tile_height`].
pub(crate) fn tile_height(&self) -> Result<u64, Error> {
self.layout.tile_size().map(|[_, height]| height.into())
}
/// `setTileBuffer:offset:atIndex:` (`None` unbinds the index). Refused as
/// [`RenderCommandEncoder::set_vertex_buffer`] is.
pub fn set_tile_buffer(
/// The lowering of [`RenderCommandEncoder::set_tile_buffer`].
pub(crate) fn set_tile_buffer(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
@@ -609,9 +606,8 @@ impl RenderCommandEncoder {
.set_buffer(&mut self.core, "set_tile_buffer", buffer, offset, index)
}
/// `setTileBuffers:offsets:withRange:`. Refused as
/// [`RenderCommandEncoder::set_vertex_buffers`] is.
pub fn set_tile_buffers(
/// The lowering of [`RenderCommandEncoder::set_tile_buffers`].
pub(crate) fn set_tile_buffers(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
@@ -629,26 +625,26 @@ impl RenderCommandEncoder {
.set_buffers(&mut self.core, "set_tile_buffers", buffers, offsets, first)
}
/// `setTileBufferOffset:atIndex:`. Refused as
/// [`RenderCommandEncoder::set_vertex_buffer_offset`] is.
pub fn set_tile_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_tile_buffer_offset`].
pub(crate) fn set_tile_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
self.log(|_| RenderCall::BufferOffset(Table::Tile, offset, index));
self.tile
.set_buffer_offset(&mut self.core, "set_tile_buffer_offset", offset, index)
}
/// `setTileBytes:length:atIndex:`: as
/// [`RenderCommandEncoder::set_vertex_bytes`], in the tile stage's table, which the pass's
/// later tile dispatches read. Refused as that is.
pub fn set_tile_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_tile_bytes`].
pub(crate) fn set_tile_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
self.log(|log| RenderCall::Bytes(Table::Tile, log.byte_span(bytes), index));
self.tile
.set_bytes(&mut self.core, "set_tile_bytes", bytes, None, index)
}
/// `setTileTexture:atIndex:` (`None` unbinds the index). Refused as
/// [`RenderCommandEncoder::set_vertex_texture`] is.
pub fn set_tile_texture(&mut self, texture: Option<&Texture>, index: u32) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::set_tile_texture`].
pub(crate) fn set_tile_texture(
&mut self,
texture: Option<&Texture>,
index: u32,
) -> Result<(), Error> {
self.log(|log| {
let texture = texture.map(|texture| log.hold_texture(texture));
RenderCall::Texture(Table::Tile, texture, index)
@@ -657,9 +653,8 @@ impl RenderCommandEncoder {
.set_textures(&mut self.core, "set_tile_texture", &[texture], index)
}
/// `setTileTextures:withRange:`. Refused as
/// [`RenderCommandEncoder::set_vertex_textures`] is.
pub fn set_tile_textures(
/// The lowering of [`RenderCommandEncoder::set_tile_textures`].
pub(crate) fn set_tile_textures(
&mut self,
textures: &[Option<&Texture>],
first: u32,
@@ -669,9 +664,8 @@ impl RenderCommandEncoder {
.set_textures(&mut self.core, "set_tile_textures", textures, first)
}
/// `setTileSamplerState:atIndex:` (`None` unbinds the index). Refused as
/// [`RenderCommandEncoder::set_vertex_sampler_state`] is.
pub fn set_tile_sampler_state(
/// The lowering of [`RenderCommandEncoder::set_tile_sampler_state`].
pub(crate) fn set_tile_sampler_state(
&mut self,
sampler: Option<&SamplerState>,
index: u32,
@@ -689,10 +683,8 @@ impl RenderCommandEncoder {
)
}
/// `setTileSamplerStates:withRange:`, or with `clamps`
/// `setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:`. Refused as
/// [`RenderCommandEncoder::set_vertex_sampler_states`] is.
pub fn set_tile_sampler_states(
/// The lowering of [`RenderCommandEncoder::set_tile_sampler_states`].
pub(crate) fn set_tile_sampler_states(
&mut self,
samplers: &[Option<&SamplerState>],
clamps: Option<(&[f32], &[f32])>,
@@ -708,26 +700,14 @@ impl RenderCommandEncoder {
)
}
/// `dispatchThreadsPerTile:`: run the tile pipeline's state set on every tile of the pass
/// (the module docs). Threads per tile of a depth other than 1 run as 1, and threads per tile
/// past Metal's limit for the state run nothing, as plain Metal runs them. Refused
/// (`Invalid`), as Metal's validation refuses it: no state set, a drawing state
/// (`DrawProblem::NotTileState`), threads per tile that are empty or wider or taller than
/// the pass's tile (`DrawProblem::ThreadsPerTilePastTile`). What the binder refuses is
/// refused (`Bind`, `Unsupported`), threads per tile within Metal's limit but past the
/// state's `max_total_threads_per_threadgroup` (this device's lower limit) among them. A
/// refused dispatch records nothing and changes nothing.
pub fn dispatch_threads_per_tile(&mut self, threads: Size) -> Result<(), Error> {
/// The lowering of [`RenderCommandEncoder::dispatch_threads_per_tile`].
pub(crate) fn dispatch_threads_per_tile(&mut self, threads: Size) -> Result<(), Error> {
self.log(|_| RenderCall::ThreadsPerTile(Box::new(threads)));
self.dispatch_tiles("dispatch_threads_per_tile", threads, None)
}
/// `dispatchThreadsPerTile:inRegion:`, or with `render_target_array_index`
/// `dispatchThreadsPerTile:inRegion:withRenderTargetArrayIndex:` (SPI): run the tile
/// pipeline's state set on the tiles of the pass that `region`'s pixels touch, each as
/// [`RenderCommandEncoder::dispatch_threads_per_tile`] runs it (the module docs). Refused as
/// that is; a region that touches no tile runs nothing.
pub fn dispatch_threads_per_tile_in_region(
/// The lowering of [`RenderCommandEncoder::dispatch_threads_per_tile_in_region`].
pub(crate) fn dispatch_threads_per_tile_in_region(
&mut self,
threads: Size,
region: Region,
@@ -1306,6 +1286,126 @@ impl RenderCommandEncoder {
}
}
impl RenderCommandEncoder {
/// `tileWidth`: the pass's tile width, or the default for its samples (32; `tile_pass.rs`).
/// Not measured (`NotImplemented(TileAtSampleCount)`) in a pass of a sample count Apple's
/// GPUs lack.
pub fn tile_width(&self) -> Result<u64, Error> {
self.lowering.tile_width()
}
/// `tileHeight`: the pass's tile height, or the default for its samples (32, and 16 at 4
/// samples; `tile_pass.rs`). Not measured as [`RenderCommandEncoder::tile_width`] is not.
pub fn tile_height(&self) -> Result<u64, Error> {
self.lowering.tile_height()
}
/// `setTileBuffer:offset:atIndex:` (`None` unbinds the index). Refused as
/// [`RenderCommandEncoder::set_vertex_buffer`] is.
pub fn set_tile_buffer(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
index: u32,
) -> Result<(), Error> {
self.lowering.set_tile_buffer(buffer, offset, index)
}
/// `setTileBuffers:offsets:withRange:`. Refused as
/// [`RenderCommandEncoder::set_vertex_buffers`] is.
pub fn set_tile_buffers(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
first: u32,
) -> Result<(), Error> {
self.lowering.set_tile_buffers(buffers, offsets, first)
}
/// `setTileBufferOffset:atIndex:`. Refused as
/// [`RenderCommandEncoder::set_vertex_buffer_offset`] is.
pub fn set_tile_buffer_offset(&mut self, offset: u64, index: u32) -> Result<(), Error> {
self.lowering.set_tile_buffer_offset(offset, index)
}
/// `setTileBytes:length:atIndex:`: as
/// [`RenderCommandEncoder::set_vertex_bytes`], in the tile stage's table, which the pass's
/// later tile dispatches read. Refused as that is.
pub fn set_tile_bytes(&mut self, bytes: &[u8], index: u32) -> Result<(), Error> {
self.lowering.set_tile_bytes(bytes, index)
}
/// `setTileTexture:atIndex:` (`None` unbinds the index). Refused as
/// [`RenderCommandEncoder::set_vertex_texture`] is.
pub fn set_tile_texture(&mut self, texture: Option<&Texture>, index: u32) -> Result<(), Error> {
self.lowering.set_tile_texture(texture, index)
}
/// `setTileTextures:withRange:`. Refused as
/// [`RenderCommandEncoder::set_vertex_textures`] is.
pub fn set_tile_textures(
&mut self,
textures: &[Option<&Texture>],
first: u32,
) -> Result<(), Error> {
self.lowering.set_tile_textures(textures, first)
}
/// `setTileSamplerState:atIndex:` (`None` unbinds the index). Refused as
/// [`RenderCommandEncoder::set_vertex_sampler_state`] is.
pub fn set_tile_sampler_state(
&mut self,
sampler: Option<&SamplerState>,
index: u32,
) -> Result<(), Error> {
self.lowering.set_tile_sampler_state(sampler, index)
}
/// `setTileSamplerStates:withRange:`, or with `clamps`
/// `setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:`. Refused as
/// [`RenderCommandEncoder::set_vertex_sampler_states`] is.
pub fn set_tile_sampler_states(
&mut self,
samplers: &[Option<&SamplerState>],
clamps: Option<(&[f32], &[f32])>,
first: u32,
) -> Result<(), Error> {
self.lowering
.set_tile_sampler_states(samplers, clamps, first)
}
/// `dispatchThreadsPerTile:`: run the tile pipeline's state set on every tile of the pass
/// (the module docs). Threads per tile of a depth other than 1 run as 1, and threads per tile
/// past Metal's limit for the state run nothing, as plain Metal runs them. Refused
/// (`Invalid`), as Metal's validation refuses it: no state set, a drawing state
/// (`DrawProblem::NotTileState`), threads per tile that are empty or wider or taller than
/// the pass's tile (`DrawProblem::ThreadsPerTilePastTile`). What the binder refuses is
/// refused (`Bind`, `Unsupported`), threads per tile within Metal's limit but past the
/// state's `max_total_threads_per_threadgroup` (this device's lower limit) among them. A
/// refused dispatch records nothing and changes nothing.
pub fn dispatch_threads_per_tile(&mut self, threads: Size) -> Result<(), Error> {
self.lowering.dispatch_threads_per_tile(threads)
}
/// `dispatchThreadsPerTile:inRegion:`, or with `render_target_array_index`
/// `dispatchThreadsPerTile:inRegion:withRenderTargetArrayIndex:` (SPI): run the tile
/// pipeline's state set on the tiles of the pass that `region`'s pixels touch, each as
/// [`RenderCommandEncoder::dispatch_threads_per_tile`] runs it (the module docs). Refused as
/// that is; a region that touches no tile runs nothing.
pub fn dispatch_threads_per_tile_in_region(
&mut self,
threads: Size,
region: Region,
render_target_array_index: Option<u32>,
) -> Result<(), Error> {
self.lowering.dispatch_threads_per_tile_in_region(
threads,
region,
render_target_array_index,
)
}
}
/// The tiles `region`'s pixels touch in a pass of `groups` tiles of `tile` pixels, per axis
/// `(first, count)`, as Metal takes the region (the module docs): in 32-bit arithmetic that wraps,
/// the first tile is `x / tile`, the end `(x + w + tile - 1) / tile`, and the count `end - first`,
@@ -48,6 +48,7 @@
use super::RenderCall;
use super::RenderCommandEncoder;
use super::RenderLowering;
use crate::argument_table::{check_index, BUFFER_SLOTS};
use crate::buffer::Buffer;
use crate::error::{internal, invalid, Error, Problem};
@@ -119,14 +120,9 @@ impl TileMemory {
}
}
impl RenderCommandEncoder {
/// `setThreadgroupMemoryLength:offset:atIndex:`: a tile or fragment function's threadgroup
/// argument `index` is `length` bytes at byte `offset` of its tile's threadgroup memory, for
/// the encoder's later tile dispatches and draws (the module docs). Refused (`Invalid`), as Metal's
/// validation refuses it: an index past the table (`IndexOutOfRange`), and a length or an
/// offset that is not a multiple of 16 bytes, or an argument that ends past the pass's
/// `threadgroupMemoryLength` (`TileThreadgroupArgument`).
pub fn set_threadgroup_memory_length(
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::set_threadgroup_memory_length`].
pub(crate) fn set_threadgroup_memory_length(
&mut self,
length: u64,
offset: u64,
@@ -157,3 +153,21 @@ impl RenderCommandEncoder {
Ok(())
}
}
impl RenderCommandEncoder {
/// `setThreadgroupMemoryLength:offset:atIndex:`: a tile or fragment function's threadgroup
/// argument `index` is `length` bytes at byte `offset` of its tile's threadgroup memory, for
/// the encoder's later tile dispatches and draws (the module docs). Refused (`Invalid`), as Metal's
/// validation refuses it: an index past the table (`IndexOutOfRange`), and a length or an
/// offset that is not a multiple of 16 bytes, or an argument that ends past the pass's
/// `threadgroupMemoryLength` (`TileThreadgroupArgument`).
pub fn set_threadgroup_memory_length(
&mut self,
length: u64,
offset: u64,
index: u32,
) -> Result<(), Error> {
self.lowering
.set_threadgroup_memory_length(length, offset, index)
}
}
@@ -21,7 +21,7 @@
//! 32-bit indices, or an indirect draw, that pulls an attribute at a stride from such a buffer
//! is refused whatever its indices or arguments hold: they are GPU memory.
use super::RenderCommandEncoder;
use super::RenderLowering;
use crate::error::{Error, RuntimeGap};
use crate::fetch_reach::{format_bytes, reach, REACHED};
use metal2vulkan::bind::DrawCall;
@@ -29,7 +29,7 @@ use metal2vulkan::metal::VertexStepFunction;
use metal2vulkan::pipeline::{PulledAttribute, VertexStride};
use metal2vulkan::vk;
impl RenderCommandEncoder {
impl RenderLowering {
/// Refuse `draw` (`NotImplemented(VertexFetchPast4GiB)`, the module docs) where it may
/// read an attribute of `pulled`, its pipeline variant's pulled attributes, past `2^32` bytes
/// of the bind offset of a buffer of the encoder's vertex table that runs past them.
@@ -22,16 +22,13 @@
use super::RenderCall;
use super::RenderCommandEncoder;
use super::RenderLowering;
use crate::buffer::Buffer;
use crate::error::Error;
impl RenderCommandEncoder {
/// `setVertexBuffer:offset:attributeStride:atIndex:`: as
/// [`set_vertex_buffer`](Self::set_vertex_buffer), the buffer read at `stride` by a layout of
/// `MTLBufferLayoutStrideDynamic` (the module docs); `MTLAttributeStrideStatic` (`u64::MAX`)
/// sets no stride; any other stride past 32 bits is taken modulo `2^32`, as plain Metal
/// reads it and its validation takes it (an M4). Refused as `set_vertex_buffer` is.
pub fn set_vertex_buffer_with_stride(
impl RenderLowering {
/// The lowering of [`RenderCommandEncoder::set_vertex_buffer_with_stride`].
pub(crate) fn set_vertex_buffer_with_stride(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
@@ -52,13 +49,8 @@ impl RenderCommandEncoder {
)
}
/// `setVertexBytes:length:attributeStride:atIndex:`: as
/// [`set_vertex_bytes`](Self::set_vertex_bytes), the bytes read at `stride`, its low 32 bits,
/// by a layout of `MTLBufferLayoutStrideDynamic`. At `MTLAttributeStrideStatic` (`u64::MAX`)
/// a draw whose layout reads them so is refused (`Bind(MissingVertexStride)`): an M4 read
/// element 0 of the bytes and zeros past it there, which the fetch does not emulate. Refused as
/// `set_vertex_bytes` is.
pub fn set_vertex_bytes_with_stride(
/// The lowering of [`RenderCommandEncoder::set_vertex_bytes_with_stride`].
pub(crate) fn set_vertex_bytes_with_stride(
&mut self,
bytes: &[u8],
stride: u64,
@@ -74,11 +66,8 @@ impl RenderCommandEncoder {
)
}
/// `setVertexBuffers:offsets:attributeStrides:withRange:`: `buffers[i]` at offset
/// `offsets[i]` and stride `strides[i]` at index `first + i`, each as
/// [`set_vertex_buffer_with_stride`](Self::set_vertex_buffer_with_stride). Refused as that
/// is, and when the slices' lengths differ; a refusal binds none of them.
pub fn set_vertex_buffers_with_strides(
/// The lowering of [`RenderCommandEncoder::set_vertex_buffers_with_strides`].
pub(crate) fn set_vertex_buffers_with_strides(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
@@ -104,11 +93,8 @@ impl RenderCommandEncoder {
)
}
/// `setVertexBufferOffset:attributeStride:atIndex:`: as
/// [`set_vertex_buffer_offset`](Self::set_vertex_buffer_offset), with the index's stride set
/// as [`set_vertex_buffer_with_stride`](Self::set_vertex_buffer_with_stride) sets it.
/// Refused as both are.
pub fn set_vertex_buffer_offset_with_stride(
/// The lowering of [`RenderCommandEncoder::set_vertex_buffer_offset_with_stride`].
pub(crate) fn set_vertex_buffer_offset_with_stride(
&mut self,
offset: u64,
stride: u64,
@@ -124,3 +110,66 @@ impl RenderCommandEncoder {
)
}
}
impl RenderCommandEncoder {
/// `setVertexBuffer:offset:attributeStride:atIndex:`: as
/// [`set_vertex_buffer`](Self::set_vertex_buffer), the buffer read at `stride` by a layout of
/// `MTLBufferLayoutStrideDynamic` (the module docs); `MTLAttributeStrideStatic` (`u64::MAX`)
/// sets no stride; any other stride past 32 bits is taken modulo `2^32`, as plain Metal
/// reads it and its validation takes it (an M4). Refused as `set_vertex_buffer` is.
pub fn set_vertex_buffer_with_stride(
&mut self,
buffer: Option<&Buffer>,
offset: u64,
stride: u64,
index: u32,
) -> Result<(), Error> {
self.lowering
.set_vertex_buffer_with_stride(buffer, offset, stride, index)
}
/// `setVertexBytes:length:attributeStride:atIndex:`: as
/// [`set_vertex_bytes`](Self::set_vertex_bytes), the bytes read at `stride`, its low 32 bits,
/// by a layout of `MTLBufferLayoutStrideDynamic`. At `MTLAttributeStrideStatic` (`u64::MAX`)
/// a draw whose layout reads them so is refused (`Bind(MissingVertexStride)`): an M4 read
/// element 0 of the bytes and zeros past it there, which the fetch does not emulate. Refused as
/// `set_vertex_bytes` is.
pub fn set_vertex_bytes_with_stride(
&mut self,
bytes: &[u8],
stride: u64,
index: u32,
) -> Result<(), Error> {
self.lowering
.set_vertex_bytes_with_stride(bytes, stride, index)
}
/// `setVertexBuffers:offsets:attributeStrides:withRange:`: `buffers[i]` at offset
/// `offsets[i]` and stride `strides[i]` at index `first + i`, each as
/// [`set_vertex_buffer_with_stride`](Self::set_vertex_buffer_with_stride). Refused as that
/// is, and when the slices' lengths differ; a refusal binds none of them.
pub fn set_vertex_buffers_with_strides(
&mut self,
buffers: &[Option<&Buffer>],
offsets: &[u64],
strides: &[u64],
first: u32,
) -> Result<(), Error> {
self.lowering
.set_vertex_buffers_with_strides(buffers, offsets, strides, first)
}
/// `setVertexBufferOffset:attributeStride:atIndex:`: as
/// [`set_vertex_buffer_offset`](Self::set_vertex_buffer_offset), with the index's stride set
/// as [`set_vertex_buffer_with_stride`](Self::set_vertex_buffer_with_stride) sets it.
/// Refused as both are.
pub fn set_vertex_buffer_offset_with_stride(
&mut self,
offset: u64,
stride: u64,
index: u32,
) -> Result<(), Error> {
self.lowering
.set_vertex_buffer_offset_with_stride(offset, stride, index)
}
}