use crate::*;
use crate::ctypes::*;
use crate::d3d::*;
use crate::d3d11::*;
use std::convert::TryInto;
use std::ptr::*;
#[derive(Clone)] #[repr(transparent)]
pub struct FunctionLinkingGraph(pub(crate) mcom::Rc<winapi::um::d3d11shader::ID3D11FunctionLinkingGraph>);
convert!(unsafe FunctionLinkingGraph => Unknown, winapi::um::d3d11shader::ID3D11FunctionLinkingGraph);
impl FunctionLinkingGraph {
pub fn call_function(
&self,
module_instance_namespace: impl TryIntoAsOptCStr,
module_with_function_prototype: &Module,
function_name: impl TryIntoAsCStr,
) -> Result<LinkingNode, MethodError> {
let ns = module_instance_namespace.try_into() .map_err(|e| MethodError::new("FunctionLinkingGraph::call_function", e))?;
let name = function_name.try_into() .map_err(|e| MethodError::new("FunctionLinkingGraph::call_function", e))?;
let module = module_with_function_prototype.as_raw();
let mut node = null_mut();
let hr = unsafe { self.0.CallFunction(ns.as_opt_cstr(), module, name.as_cstr(), &mut node) };
MethodError::check("ID3D11FunctionLinkingGraph::CallFunction", hr)?;
Ok(unsafe { LinkingNode::from_raw(node) })
}
pub fn create_module_instance(&self) -> Result<(ModuleInstance, Option<ReadOnlyBlob>), MethodErrorBlob> {
let mut module = null_mut();
let mut errors = null_mut();
let hr = unsafe { self.0.CreateModuleInstance(&mut module, &mut errors) };
unsafe { MethodErrorBlob::check_blob("ID3D11FunctionLinkingGraph::CreateModuleInstance", hr, errors)? };
let module = unsafe { ModuleInstance::from_raw(module) };
let errors = unsafe { ReadOnlyBlob::from_raw_opt(errors) };
Ok((module, errors))
}
pub fn generate_hlsl(&self, flags: ()) -> Result<TextBlob, MethodError> {
let _ = flags; let flags = 0;
let mut blob = null_mut();
let hr = unsafe { self.0.GenerateHlsl(flags, &mut blob) };
MethodError::check("ID3D11FunctionLinkingGraph::GenerateHlsl", hr)?;
Ok(TextBlob::new(unsafe { ReadOnlyBlob::from_raw(blob) }))
}
pub fn get_last_error(&self) -> Result<TextBlob, MethodError> {
let mut errors = null_mut();
let hr = unsafe { self.0.GetLastError(&mut errors) };
MethodError::check("ID3D11FunctionLinkingGraph::GetLastError", hr)?;
Ok(TextBlob::new(unsafe { ReadOnlyBlob::from_raw_opt(errors) }))
}
pub fn pass_value(&self, src_node: &LinkingNode, src_parameter_index: i32, dst_node: &LinkingNode, dst_parameter_index: i32) -> Result<(), MethodError> {
let hr = unsafe { self.0.PassValue(src_node.as_raw(), src_parameter_index, dst_node.as_raw(), dst_parameter_index) };
MethodError::check("ID3D11FunctionLinkingGraph::PassValue", hr)
}
pub fn pass_value_with_swizzle(&self, src_node: &LinkingNode, src_parameter_index: i32, src_swizzle: impl TryIntoAsCStr, dst_node: &LinkingNode, dst_parameter_index: i32, dst_swizzle: impl TryIntoAsCStr) -> Result<(), MethodError> {
let src_swizzle = src_swizzle.try_into().map_err(|e| MethodError::new("FunctionLinkingGraph::pass_value_with_swizzle", e))?;
let dst_swizzle = dst_swizzle.try_into().map_err(|e| MethodError::new("FunctionLinkingGraph::pass_value_with_swizzle", e))?;
let hr = unsafe { self.0.PassValueWithSwizzle(src_node.as_raw(), src_parameter_index, src_swizzle.as_cstr(), dst_node.as_raw(), dst_parameter_index, dst_swizzle.as_cstr()) };
MethodError::check("ID3D11FunctionLinkingGraph::PassValueWithSwizzle", hr)
}
pub fn set_input_signature(&self, input_parameters: &[ParameterDesc<'static>]) -> Result<LinkingNode, MethodError> {
let n = input_parameters.len().try_into().map_err(|_| MethodError::new("ID3D11FunctionLinkingGraph::SetInputSignature", THINERR::SLICE_TOO_LARGE))?;
let mut node = null_mut();
let hr = unsafe { self.0.SetInputSignature(input_parameters.as_ptr().cast(), n, &mut node) };
MethodError::check("ID3D11FunctionLinkingGraph::SetInputSignature", hr)?;
Ok(unsafe { LinkingNode::from_raw(node) })
}
pub fn set_output_signature(&self, output_parameters: &[ParameterDesc<'static>]) -> Result<LinkingNode, MethodError> {
let n = output_parameters.len().try_into().map_err(|_| MethodError::new("ID3D11FunctionLinkingGraph::SetOutputSignature", THINERR::SLICE_TOO_LARGE))?;
let mut node = null_mut();
let hr = unsafe { self.0.SetOutputSignature(output_parameters.as_ptr().cast(), n, &mut node) };
MethodError::check("ID3D11FunctionLinkingGraph::SetOutputSignature", hr)?;
Ok(unsafe { LinkingNode::from_raw(node) })
}
}