Skip to content

Commit

Permalink
Mesh Shader Support in raft-api for DX12 and Metal (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
aclysma authored Aug 4, 2024
1 parent e96177d commit c3aed40
Show file tree
Hide file tree
Showing 29 changed files with 1,175 additions and 194 deletions.
8 changes: 4 additions & 4 deletions rafx-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ backtrace = { version = "0.3", optional = true }
raw-window-handle = "0.5"

# vulkan/dx12
gpu-allocator = { version = "0.22.0", default_features = false, optional = true }
gpu-allocator = { version = "0.22.0", default-features = false, optional = true }

# vulkan
ash = { version = "0.37", optional = true }
ash-window = { version = "0.12", optional = true }

# dx12
windows = { version = "0.44", optional=true, features = ["Win32_Foundation", "Win32_Graphics_Dxgi_Common", "Win32_Security", "Win32_System", "Win32_System_Threading", "Win32_Graphics_Direct3D", "Win32_Graphics_Direct3D12", "Win32_Graphics_Dxgi", "Win32_Graphics_Direct3D_Dxc"] }
hassle-rs = { version = "0.10.0", optional=true }
windows = { version = "0.44", optional = true, features = ["Win32_Foundation", "Win32_Graphics_Dxgi_Common", "Win32_Security", "Win32_System", "Win32_System_Threading", "Win32_Graphics_Direct3D", "Win32_Graphics_Direct3D12", "Win32_Graphics_Dxgi", "Win32_Graphics_Direct3D_Dxc"] }
hassle-rs = { version = "0.10.0", optional = true }

# metal
[target.'cfg(target_os="macos")'.dependencies]
metal_rs = { package = "metal", version = "0.25", optional = true }
metal_rs = { package = "metal", version = "0.28", optional = true }
core-graphics-types = { version = "0.1", optional = true }
# Force core-graphics-0.22.3 due to semver breakage
# https://github.com/servo/core-foundation-rs/pull/562
Expand Down
21 changes: 18 additions & 3 deletions rafx-api/src/backends/dx12/command_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use super::d3d12;
pub struct RafxCommandBufferDx12Inner {
//command_list_type: d3d12::D3D12_COMMAND_LIST_TYPE,
command_list_base: d3d12::ID3D12CommandList,
command_list: d3d12::ID3D12GraphicsCommandList,
command_list: d3d12::ID3D12GraphicsCommandList6,
command_allocator: d3d12::ID3D12CommandAllocator,
bound_root_signature: Option<d3d12::ID3D12RootSignature>,

Expand All @@ -45,7 +45,7 @@ impl RafxCommandBufferDx12 {
self.inner.borrow().command_list_base.clone()
}

pub fn dx12_graphics_command_list(&self) -> d3d12::ID3D12GraphicsCommandList {
pub fn dx12_graphics_command_list(&self) -> d3d12::ID3D12GraphicsCommandList6 {
self.inner.borrow().command_list.clone()
}

Expand Down Expand Up @@ -87,7 +87,7 @@ impl RafxCommandBufferDx12 {
//TODO: Special handling for copy?
let command_list_type = command_pool.command_list_type();
let command_list = unsafe {
let command_list: d3d12::ID3D12GraphicsCommandList = command_pool
let command_list: d3d12::ID3D12GraphicsCommandList6 = command_pool
.queue()
.device_context()
.d3d12_device()
Expand Down Expand Up @@ -716,6 +716,21 @@ impl RafxCommandBufferDx12 {
Ok(())
}

pub fn cmd_draw_mesh(
&self,
group_count_x: u32,
group_count_y: u32,
group_count_z: u32,
) -> RafxResult<()> {
let inner = self.inner.borrow();
unsafe {
inner
.command_list
.DispatchMesh(group_count_x, group_count_y, group_count_z);
}
Ok(())
}

pub fn cmd_dispatch(
&self,
group_count_x: u32,
Expand Down
2 changes: 1 addition & 1 deletion rafx-api/src/backends/dx12/internal/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub fn blend_state_blend_state_desc(
|| def.src_factor_alpha != RafxBlendFactor::One
|| def.dst_factor_alpha != RafxBlendFactor::Zero;

let mut desc = &mut blend_desc.RenderTarget[attachment_index as usize];
let desc = &mut blend_desc.RenderTarget[attachment_index as usize];
desc.BlendEnable = blend_enable.into();
desc.RenderTargetWriteMask = def.masks.bits();
desc.BlendOp = def.blend_op.into();
Expand Down
7 changes: 1 addition & 6 deletions rafx-api/src/backends/dx12/internal/mipmap_resources.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use super::d3d12;
use crate::dx12::RafxDeviceContextDx12;
use crate::{
RafxComputePipelineDef, RafxImmutableSamplerKey, RafxImmutableSamplers, RafxPipeline,
RafxResourceType, RafxResult, RafxRootSignature, RafxRootSignatureDef, RafxSampler,
RafxSamplerDef, RafxShader, RafxShaderModule, RafxShaderModuleDefDx12, RafxShaderResource,
RafxShaderStageDef, RafxShaderStageFlags, RafxShaderStageReflection,
};
use crate::RafxResult;

pub struct Dx12MipmapResources {
//pub shader: RafxShader,
Expand Down
Loading

0 comments on commit c3aed40

Please sign in to comment.