Skip to content

Commit

Permalink
Add Dx11 Api
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Jan 30, 2022
1 parent 766c6cd commit 376afd5
Show file tree
Hide file tree
Showing 10 changed files with 649 additions and 4 deletions.
2 changes: 1 addition & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ hal = { path = "../wgpu-hal", package = "wgpu-hal", version = "0.12", features =
hal = { path = "../wgpu-hal", package = "wgpu-hal", version = "0.12", features = ["vulkan", "gles", "renderdoc"] }

[target.'cfg(all(not(target_arch = "wasm32"), windows))'.dependencies]
hal = { path = "../wgpu-hal", package = "wgpu-hal", version = "0.12", features = ["vulkan", "dx12", "renderdoc"] }
hal = { path = "../wgpu-hal", package = "wgpu-hal", version = "0.12", features = ["vulkan", "dx12", "dx11", "renderdoc"] }

[target.'cfg(target_os = "emscripten")'.dependencies]
hal = { path = "../wgpu-hal", package = "wgpu-hal", version = "0.12", features = ["emscripten"] }
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
vulkan: { all(not(wasm), any(windows, unix_wo_apple)) },
metal: { all(not(wasm), apple) },
dx12: { all(not(wasm), windows) },
dx11: { all(false, not(wasm), windows) },
dx11: { all(not(wasm), windows) },
gl: {
any(
unix_wo_apple,
Expand Down
9 changes: 7 additions & 2 deletions wgpu-core/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,10 +1038,16 @@ impl HalApi for hal::api::Dx12 {
}
}

/*
#[cfg(dx11)]
impl HalApi for hal::api::Dx11 {
const VARIANT: Backend = Backend::Dx11;
fn create_instance_from_hal(name: &str, hal_instance: Self::Instance) -> Instance {
Instance {
name: name.to_owned(),
dx11: Some(hal_instance),
..Default::default()
}
}
fn hub<G: GlobalIdentityHandlerFactory>(global: &Global<G>) -> &Hub<Self, G> {
&global.hubs.dx11
}
Expand All @@ -1052,7 +1058,6 @@ impl HalApi for hal::api::Dx11 {
surface.dx11.as_mut().unwrap()
}
}
*/

#[cfg(gl)]
impl HalApi for hal::api::Gles {
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ default = []
metal = ["naga/msl-out", "block", "foreign-types"]
vulkan = ["naga/spv-out", "ash", "gpu-alloc", "gpu-descriptor", "libloading", "inplace_it"]
gles = ["naga/glsl-out", "glow", "egl", "libloading"]
dx11 = ["naga/hlsl-out", "winapi/d3d11", "winapi/d3d11_1", "winapi/d3d11sdklayers", "winapi/dxgi1_6"]
dx12 = ["naga/hlsl-out", "native", "bit-set", "range-alloc", "winapi/d3d12", "winapi/d3d12shader", "winapi/d3d12sdklayers", "winapi/dxgi1_6"]
renderdoc = ["libloading", "renderdoc-sys"]
emscripten = ["gles"]
Expand Down
23 changes: 23 additions & 0 deletions wgpu-hal/src/dx11/adapter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
impl crate::Adapter<super::Api> for super::Adapter {
unsafe fn open(
&self,
features: wgt::Features,
limits: &wgt::Limits,
) -> Result<crate::OpenDevice<super::Api>, crate::DeviceError> {
todo!()
}

unsafe fn texture_format_capabilities(
&self,
format: wgt::TextureFormat,
) -> crate::TextureFormatCapabilities {
todo!()
}

unsafe fn surface_capabilities(
&self,
surface: &super::Surface,
) -> Option<crate::SurfaceCapabilities> {
todo!()
}
}
268 changes: 268 additions & 0 deletions wgpu-hal/src/dx11/command.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> {
todo!()
}

unsafe fn discard_encoding(&mut self) {
todo!()
}

unsafe fn end_encoding(&mut self) -> Result<super::CommandBuffer, crate::DeviceError> {
todo!()
}

unsafe fn reset_all<I>(&mut self, command_buffers: I)
where
I: Iterator<Item = super::CommandBuffer>,
{
todo!()
}

unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where
T: Iterator<Item = crate::BufferBarrier<'a, super::Api>>,
{
todo!()
}

unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
where
T: Iterator<Item = crate::TextureBarrier<'a, super::Api>>,
{
todo!()
}

unsafe fn clear_buffer(&mut self, buffer: &super::Buffer, range: crate::MemoryRange) {
todo!()
}

unsafe fn copy_buffer_to_buffer<T>(
&mut self,
src: &super::Buffer,
dst: &super::Buffer,
regions: T,
) where
T: Iterator<Item = crate::BufferCopy>,
{
todo!()
}

unsafe fn copy_texture_to_texture<T>(
&mut self,
src: &super::Texture,
src_usage: crate::TextureUses,
dst: &super::Texture,
regions: T,
) where
T: Iterator<Item = crate::TextureCopy>,
{
todo!()
}

unsafe fn copy_buffer_to_texture<T>(
&mut self,
src: &super::Buffer,
dst: &super::Texture,
regions: T,
) where
T: Iterator<Item = crate::BufferTextureCopy>,
{
todo!()
}

unsafe fn copy_texture_to_buffer<T>(
&mut self,
src: &super::Texture,
src_usage: crate::TextureUses,
dst: &super::Buffer,
regions: T,
) where
T: Iterator<Item = crate::BufferTextureCopy>,
{
todo!()
}

unsafe fn set_bind_group(
&mut self,
layout: &super::PipelineLayout,
index: u32,
group: &super::BindGroup,
dynamic_offsets: &[wgt::DynamicOffset],
) {
todo!()
}

unsafe fn set_push_constants(
&mut self,
layout: &super::PipelineLayout,
stages: wgt::ShaderStages,
offset: u32,
data: &[u32],
) {
todo!()
}

unsafe fn insert_debug_marker(&mut self, label: &str) {
todo!()
}

unsafe fn begin_debug_marker(&mut self, group_label: &str) {
todo!()
}

unsafe fn end_debug_marker(&mut self) {
todo!()
}

unsafe fn begin_query(&mut self, set: &super::QuerySet, index: u32) {
todo!()
}

unsafe fn end_query(&mut self, set: &super::QuerySet, index: u32) {
todo!()
}

unsafe fn write_timestamp(&mut self, set: &super::QuerySet, index: u32) {
todo!()
}

unsafe fn reset_queries(&mut self, set: &super::QuerySet, range: std::ops::Range<u32>) {
todo!()
}

unsafe fn copy_query_results(
&mut self,
set: &super::QuerySet,
range: std::ops::Range<u32>,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
stride: wgt::BufferSize,
) {
todo!()
}

unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
todo!()
}

unsafe fn end_render_pass(&mut self) {
todo!()
}

unsafe fn set_render_pipeline(&mut self, pipeline: &super::RenderPipeline) {
todo!()
}

unsafe fn set_index_buffer<'a>(
&mut self,
binding: crate::BufferBinding<'a, super::Api>,
format: wgt::IndexFormat,
) {
todo!()
}

unsafe fn set_vertex_buffer<'a>(
&mut self,
index: u32,
binding: crate::BufferBinding<'a, super::Api>,
) {
todo!()
}

unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth_range: std::ops::Range<f32>) {
todo!()
}

unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect<u32>) {
todo!()
}

unsafe fn set_stencil_reference(&mut self, value: u32) {
todo!()
}

unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {
todo!()
}

unsafe fn draw(
&mut self,
start_vertex: u32,
vertex_count: u32,
start_instance: u32,
instance_count: u32,
) {
todo!()
}

unsafe fn draw_indexed(
&mut self,
start_index: u32,
index_count: u32,
base_vertex: i32,
start_instance: u32,
instance_count: u32,
) {
todo!()
}

unsafe fn draw_indirect(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
) {
todo!()
}

unsafe fn draw_indexed_indirect(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
) {
todo!()
}

unsafe fn draw_indirect_count(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
count_buffer: &super::Buffer,
count_offset: wgt::BufferAddress,
max_count: u32,
) {
todo!()
}

unsafe fn draw_indexed_indirect_count(
&mut self,
buffer: &super::Buffer,
offset: wgt::BufferAddress,
count_buffer: &super::Buffer,
count_offset: wgt::BufferAddress,
max_count: u32,
) {
todo!()
}

unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor) {
todo!()
}

unsafe fn end_compute_pass(&mut self) {
todo!()
}

unsafe fn set_compute_pipeline(&mut self, pipeline: &super::ComputePipeline) {
todo!()
}

unsafe fn dispatch(&mut self, count: [u32; 3]) {
todo!()
}

unsafe fn dispatch_indirect(&mut self, buffer: &super::Buffer, offset: wgt::BufferAddress) {
todo!()
}
}
Loading

0 comments on commit 376afd5

Please sign in to comment.