byte-engine-ghi 0.1.0

Graphics hardware interface layer used by Byte-Engine.
use utils::Extent;

use crate::{
	buffer, image, pipelines::VertexElement, sampler, shader::Sources, window, AllocationHandle, BaseBufferHandle,
	BottomLevelAccelerationStructure, BottomLevelAccelerationStructureHandle, BufferHandle, CommandBufferHandle,
	DescriptorSetHandle, DeviceAccesses, DynamicBufferHandle, Formats, ImageHandle, MeshHandle, PipelineHandle,
	PresentationModes, QueueHandle, SamplerHandle, ShaderHandle, ShaderTypes, SwapchainHandle, SynchronizerHandle,
	TextureCopyHandle, TopLevelAccelerationStructureHandle, Uses,
};

pub struct Device {}

impl Default for Device {
	fn default() -> Self {
		Self::new()
	}
}

impl Device {
	pub fn new() -> Self {
		Device {}
	}

	#[cfg(any(debug_assertions, test))]
	pub fn has_errors(&self) -> bool {
		false
	}

	pub fn set_frames_in_flight(&mut self, _frames: u8) {}

	pub fn create_allocation(
		&mut self,
		_size: usize,
		_resource_uses: Uses,
		_resource_device_accesses: DeviceAccesses,
	) -> AllocationHandle {
		AllocationHandle(0)
	}

	pub fn add_mesh_from_vertices_and_indices(
		&mut self,
		_vertex_count: u32,
		_index_count: u32,
		_vertices: &[u8],
		_indices: &[u8],
		_vertex_layout: &[VertexElement],
	) -> MeshHandle {
		MeshHandle(0)
	}

	pub fn create_shader(
		&mut self,
		_name: Option<&str>,
		_shader_source_type: Sources,
		_stage: ShaderTypes,
		_shader_resource_descriptors: impl IntoIterator<Item = crate::shader::ShaderResourceDescriptor>,
	) -> Result<ShaderHandle, ()> {
		Ok(ShaderHandle(0))
	}

	pub fn create_descriptor_set(&mut self, _name: Option<&str>) -> DescriptorSetHandle {
		DescriptorSetHandle(0)
	}

	pub fn create_raster_pipeline(&mut self, _builder: crate::pipelines::raster::Builder) -> PipelineHandle {
		PipelineHandle(0)
	}

	pub fn create_compute_pipeline(&mut self, _builder: crate::pipelines::compute::Builder) -> PipelineHandle {
		PipelineHandle(0)
	}

	pub fn create_ray_tracing_pipeline(&mut self, _builder: crate::pipelines::ray_tracing::Builder) -> PipelineHandle {
		PipelineHandle(0)
	}

	pub fn create_command_buffer(&mut self, _name: Option<&str>, _queue_handle: QueueHandle) -> CommandBufferHandle {
		CommandBufferHandle(0)
	}

	pub fn create_command_buffer_recording<'a>(
		&'a mut self,
		command_buffer_handle: CommandBufferHandle,
	) -> super::CommandBufferRecording<'a> {
		super::CommandBufferRecording::new(self, command_buffer_handle, Vec::new(), Vec::new(), None)
	}

	pub fn build_buffer<T: Copy>(&mut self, _builder: buffer::Builder) -> BufferHandle<T> {
		todo!()
	}

	pub fn build_dynamic_buffer<T: Copy>(&mut self, _builder: buffer::Builder) -> DynamicBufferHandle<T> {
		todo!()
	}

	pub fn build_dynamic_image(&mut self, _builder: image::Builder) -> crate::DynamicImageHandle {
		crate::DynamicImageHandle(crate::BaseImageHandle(0))
	}

	pub fn get_buffer_address(&self, _buffer_handle: BaseBufferHandle) -> u64 {
		0
	}

	pub fn get_buffer_slice<T: Copy>(&mut self, _buffer_handle: BufferHandle<T>) -> &T {
		todo!("Handle true allocations");
	}

	pub fn get_mut_buffer_slice<T: Copy>(&self, _buffer_handle: BufferHandle<T>) -> &mut T {
		todo!("Handle true allocations");
	}

	pub fn get_texture_slice_mut(&mut self, _texture_handle: ImageHandle) -> &'static mut [u8] {
		&mut []
	}

	pub fn write_texture(&mut self, _texture_handle: ImageHandle, _f: impl FnOnce(&mut [u8])) {}

	pub fn build_image(&mut self, _builder: image::Builder) -> ImageHandle {
		ImageHandle(crate::BaseImageHandle(0))
	}

	pub fn build_sampler(&mut self, _builder: sampler::Builder) -> SamplerHandle {
		SamplerHandle(0)
	}

	pub fn create_acceleration_structure_instance_buffer(
		&mut self,
		_name: Option<&str>,
		_max_instance_count: u32,
	) -> BaseBufferHandle {
		BaseBufferHandle(0)
	}

	pub fn create_top_level_acceleration_structure(
		&mut self,
		_name: Option<&str>,
		_max_instance_count: u32,
	) -> TopLevelAccelerationStructureHandle {
		TopLevelAccelerationStructureHandle(0)
	}

	pub fn create_bottom_level_acceleration_structure(
		&mut self,
		_description: &BottomLevelAccelerationStructure,
	) -> BottomLevelAccelerationStructureHandle {
		BottomLevelAccelerationStructureHandle(0)
	}

	pub fn write(&mut self, _descriptor_set_writes: &[crate::descriptors::DescriptorWrite]) {}

	pub fn write_instance(
		&mut self,
		_instances_buffer_handle: BaseBufferHandle,
		_instance_index: usize,
		_transform: [[f32; 4]; 3],
		_custom_index: u16,
		_mask: u8,
		_sbt_record_offset: usize,
		_acceleration_structure: BottomLevelAccelerationStructureHandle,
	) {
	}

	pub fn write_sbt_entry(
		&mut self,
		_sbt_buffer_handle: BaseBufferHandle,
		_sbt_record_offset: usize,
		_pipeline_handle: PipelineHandle,
		_shader_handle: ShaderHandle,
	) {
	}

	pub fn bind_to_window(
		&mut self,
		_window_os_handles: &window::Handles,
		_presentation_mode: PresentationModes,
		_fallback_extent: Extent,
	) -> SwapchainHandle {
		SwapchainHandle(0)
	}

	pub fn get_swapchain_image(&mut self, _swapchain_handle: SwapchainHandle, _uses: Uses) -> (ImageHandle, Formats) {
		(ImageHandle(crate::BaseImageHandle(0)), Formats::BGRAu8)
	}

	pub fn get_image_data(&mut self, _texture_copy_handle: TextureCopyHandle) -> &[u8] {
		&[]
	}

	pub fn create_synchronizer(&mut self, _name: Option<&str>, _signaled: bool) -> SynchronizerHandle {
		SynchronizerHandle(0)
	}

	pub fn start_frame<'a>(&'a mut self, index: u32, _synchronizer_handle: SynchronizerHandle) -> super::Frame<'a> {
		let frame_key = crate::FrameKey {
			frame_index: index,
			sequence_index: 0,
		};
		super::Frame::new(self, frame_key)
	}

	pub fn resize_buffer<T: Copy>(&mut self, _buffer_handle: DynamicBufferHandle<T>, _size: usize) {}

	pub fn start_frame_capture(&self) {}

	pub fn end_frame_capture(&self) {}

	pub fn wait(&self) {}
}