Struct thindx::d3d11::ShaderReflection
source · [−]#[repr(transparent)]pub struct ShaderReflection(_);
Expand description
[docs.microsoft.com] ID3D11ShaderReflection
A shader-reflection interface accesses shader information.
Example
let d3dc = d3d::Compiler::load_system(47).unwrap();
let vs = d3dc.compile_from_file(
r"test\data\basic.hlsl", None, None, "vs_main", "vs_4_0",
d3d::Compile::Debug, d3d::CompileEffect::None
).unwrap();
let _vs : d3d11::ShaderReflection = d3dc.reflect(&vs).unwrap();
let vs = d3dc.reflect11(&vs).unwrap();
See Also
Implementations
sourceimpl ShaderReflection
impl ShaderReflection
sourcepub fn get_bitwise_instruction_count(&self) -> u32
pub fn get_bitwise_instruction_count(&self) -> u32
[docs.microsoft.com] ID3D11ShaderReflection::GetBitwiseInstructionCount
Gets the number of bitwise instructions.
Example
let count = vs.get_bitwise_instruction_count();
sourcepub fn get_constant_buffer_by_index(
&self,
index: u32
) -> ShaderReflectionConstantBuffer<'_>
pub fn get_constant_buffer_by_index(
&self,
index: u32
) -> ShaderReflectionConstantBuffer<'_>
[docs.microsoft.com] ID3D11ShaderReflection::GetConstantBufferByIndex
Get a constant buffer by index.
Returns
- If the index is out of bounds, a stub object will still be returned. The stub object will return E::FAIL from most methods.
Example
let cb0 = vs.get_constant_buffer_by_index(0);
let _ = cb0.get_desc().unwrap();
let cb1 = vs.get_constant_buffer_by_index(1);
assert_eq!(E::FAIL, cb1.get_desc());
sourcepub fn get_constant_buffer_by_name(
&self,
name: impl TryIntoAsCStr
) -> ShaderReflectionConstantBuffer<'_>
pub fn get_constant_buffer_by_name(
&self,
name: impl TryIntoAsCStr
) -> ShaderReflectionConstantBuffer<'_>
[docs.microsoft.com] ID3D11ShaderReflection::GetConstantBufferByName
Get a constant buffer by name.
Returns
- If the name doesn’t match a valid constant buffer, a stub object will still be returned. The stub object will return E::FAIL from most methods.
Example
let cb0 = vs.get_constant_buffer_by_name("ExampleCBuffer");
let _ = cb0.get_desc().unwrap();
let cb1 = vs.get_constant_buffer_by_name("Invalid");
assert_eq!(E::FAIL, cb1.get_desc());
sourcepub fn get_conversion_instruction_count(&self) -> u32
pub fn get_conversion_instruction_count(&self) -> u32
[docs.microsoft.com] ID3D11ShaderReflection::GetConversionInstructionCount
Gets the number of conversion instructions.
Example
let count : u32 = vs.get_conversion_instruction_count();
sourcepub fn get_desc(&self) -> Result<ShaderDesc<'_>, Error>
pub fn get_desc(&self) -> Result<ShaderDesc<'_>, Error>
[docs.microsoft.com] ID3D11ShaderReflection::GetDesc
Get a shader description.
Errors
- …perhaps
E::FAIL
if reflection was called on invalid or incompatible bytecode?
Example
let desc = vs.get_desc().unwrap();
assert_eq!(desc.version.ty(), d3d11::ShVer::VertexShader);
assert_eq!(desc.version.major(), 4);
assert_eq!(desc.version.minor(), 0);
sourcepub fn get_gs_input_primitive(&self) -> Primitive
pub fn get_gs_input_primitive(&self) -> Primitive
[docs.microsoft.com] ID3D11ShaderReflection::GetGSInputPrimitive
Gets the geometry-shader input-primitive description.
Returns
d3d::Primitive::Undefined
ifself
is not a geometry shader
Example
assert_eq!(vs.get_gs_input_primitive(), d3d::Primitive::Undefined);
sourcepub fn get_input_parameter_desc(
&self,
parameter_index: u32
) -> Result<SignatureParameterDesc<'_>, Error>
pub fn get_input_parameter_desc(
&self,
parameter_index: u32
) -> Result<SignatureParameterDesc<'_>, Error>
[docs.microsoft.com] ID3D11ShaderReflection::GetInputParameterDesc
Get an input-parameter description for a shader.
Errors
- E::INVALIDARG - if
parameter_index
>=self.get_desc().unwrap().input_parameters
Example
assert_eq!(0, vs.get_input_parameter_desc(0).unwrap().semantic_index);
assert_eq!(0, vs.get_input_parameter_desc(1).unwrap().semantic_index);
assert_eq!(E::INVALIDARG, vs.get_input_parameter_desc(2));
sourcepub fn get_min_feature_level(&self) -> Result<FeatureLevel, Error>
pub fn get_min_feature_level(&self) -> Result<FeatureLevel, Error>
[docs.microsoft.com] ID3D11ShaderReflection::GetMinFeatureLevel
Gets the minimum feature level.
Errors
- …?
Example
assert_eq!(vs.get_min_feature_level().unwrap(), d3d::FeatureLevel::_10_0);
sourcepub fn get_movc_instruction_count(&self) -> u32
pub fn get_movc_instruction_count(&self) -> u32
[docs.microsoft.com] ID3D11ShaderReflection::GetMovcInstructionCount
Gets the number of Movc instructions.
Example
let count = vs.get_movc_instruction_count();
sourcepub fn get_mov_instruction_count(&self) -> u32
pub fn get_mov_instruction_count(&self) -> u32
[docs.microsoft.com] ID3D11ShaderReflection::GetMovInstructionCount
Gets the number of Mov instructions.
Example
let count : u32 = vs.get_mov_instruction_count();
sourcepub fn get_num_interface_slots(&self) -> u32
pub fn get_num_interface_slots(&self) -> u32
[docs.microsoft.com] ID3D11ShaderReflection::GetNumInterfaceSlots
Gets the number of interface slots in a shader.
Example
let slots : u32 = vs.get_num_interface_slots();
sourcepub fn get_output_parameter_desc(
&self,
parameter_index: u32
) -> Result<SignatureParameterDesc<'_>, Error>
pub fn get_output_parameter_desc(
&self,
parameter_index: u32
) -> Result<SignatureParameterDesc<'_>, Error>
[docs.microsoft.com] ID3D11ShaderReflection::GetOutputParameterDesc
Get an output-parameter description for a shader.
Errors
- E::INVALIDARG - if
parameter_index
>=self.get_desc().unwrap().output_parameters
Example
assert_eq!(0, vs.get_output_parameter_desc(0).unwrap().semantic_index);
assert_eq!(0, vs.get_output_parameter_desc(1).unwrap().semantic_index);
assert_eq!(E::INVALIDARG, vs.get_output_parameter_desc(2));
sourcepub fn get_patch_constant_parameter_desc(
&self,
parameter_index: u32
) -> Result<SignatureParameterDesc<'_>, Error>
pub fn get_patch_constant_parameter_desc(
&self,
parameter_index: u32
) -> Result<SignatureParameterDesc<'_>, Error>
[docs.microsoft.com] ID3D11ShaderReflection::GetPatchConstantParameterDesc
Get a patch-constant parameter description for a shader.
Errors
- E::INVALIDARG - if
parameter_index
>=self.get_desc().unwrap().patch_constant_parameters
Example
// TODO: proper examples
assert_eq!(E::INVALIDARG, vs.get_patch_constant_parameter_desc(2));
sourcepub fn get_requires_flags(&self) -> ShaderRequires
pub fn get_requires_flags(&self) -> ShaderRequires
[docs.microsoft.com] ID3D11ShaderReflection::GetRequiresFlags
Gets a group of flags that indicates the requirements of a shader.
Example
assert_eq!(vs.get_requires_flags(), d3d::ShaderRequires::None);
sourcepub fn get_resource_binding_desc(
&self,
resource_index: u32
) -> Result<ShaderInputBindDesc<'_>, Error>
pub fn get_resource_binding_desc(
&self,
resource_index: u32
) -> Result<ShaderInputBindDesc<'_>, Error>
[docs.microsoft.com] ID3D11ShaderReflection::GetResourceBindingDesc
Get a description of how a resource is bound to a shader.
Errors
- E::INVALIDARG - if
resource_index
>=self.get_desc().unwrap().bound_resources
Example
let ex = vs.get_resource_binding_desc(0).unwrap();
assert_eq!(ex.ty, d3d::SIT::CBuffer);
assert_eq!(E::INVALIDARG, vs.get_resource_binding_desc(1));
sourcepub fn get_resource_binding_desc_by_name(
&self,
name: impl TryIntoAsCStr
) -> Result<ShaderInputBindDesc<'_>, Error>
pub fn get_resource_binding_desc_by_name(
&self,
name: impl TryIntoAsCStr
) -> Result<ShaderInputBindDesc<'_>, Error>
[docs.microsoft.com] ID3D11ShaderReflection::GetResourceBindingDescByName
Get a description of how a resource is bound to a shader.
Errors
- E::INVALIDARG - If
name
doesn’t name a valid resource binding for the shader
Example
let ex = vs.get_resource_binding_desc_by_name("ExampleCBuffer").unwrap();
assert_eq!(ex.ty, d3d::SIT::CBuffer);
assert_eq!(E::INVALIDARG, vs.get_resource_binding_desc_by_name("Invalid"));
assert_eq!(E::INVALIDARG, vs.get_resource_binding_desc_by_name("ExampleCBuffer\0"));
assert_eq!(E::INVALIDARG, vs.get_resource_binding_desc_by_name(""));
sourcepub fn get_thread_group_size(&self) -> (u32, u32, u32)
pub fn get_thread_group_size(&self) -> (u32, u32, u32)
[docs.microsoft.com] ID3D11ShaderReflection::GetThreadGroupSize
Retrieves the sizes, in units of threads, of the X, Y, and Z dimensions of the shader’s thread-group grid.
Returns
(0, 0, 0)
if not specified
Example
assert_eq!(vs.get_thread_group_size(), (0, 0, 0));
sourcepub fn get_variable_by_name(
&self,
name: impl TryIntoAsCStr
) -> ShaderReflectionVariable<'_>
pub fn get_variable_by_name(
&self,
name: impl TryIntoAsCStr
) -> ShaderReflectionVariable<'_>
[docs.microsoft.com] ID3D11ShaderReflection::GetVariableByName
Gets a variable by name.
Returns
- If
name
doesn’t name a valid cbuffer variable, a stub object will still be returned. The stub object will return E::FAIL from most methods.
Example
let tint = vs.get_variable_by_name("tint").get_desc().unwrap();
assert_eq!(tint.start_offset, 0, "unexpected tint.start_offset");
assert_eq!(tint.size, 16, "unexpected tint.size");
assert_eq!(E::FAIL, vs.get_variable_by_name("invalid").get_desc());
sourcepub fn is_sample_frequency_shader(&self) -> bool
pub fn is_sample_frequency_shader(&self) -> bool
[docs.microsoft.com] ID3D11ShaderReflection::IsSampleFrequencyShader
Indicates whether a shader is a sample frequency shader.
Example
assert_eq!(vs.is_sample_frequency_shader(), false);
Trait Implementations
sourceimpl Clone for ShaderReflection
impl Clone for ShaderReflection
sourcefn clone(&self) -> ShaderReflection
fn clone(&self) -> ShaderReflection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Deref for ShaderReflection
impl Deref for ShaderReflection
sourceimpl From<&Rc<ID3D11ShaderReflection>> for &ShaderReflection
impl From<&Rc<ID3D11ShaderReflection>> for &ShaderReflection
sourceimpl From<&ShaderReflection> for &Rc<ID3D11ShaderReflection>
impl From<&ShaderReflection> for &Rc<ID3D11ShaderReflection>
sourcefn from(value: &ShaderReflection) -> Self
fn from(value: &ShaderReflection) -> Self
Converts to this type from the input type.
sourceimpl From<Rc<ID3D11ShaderReflection>> for ShaderReflection
impl From<Rc<ID3D11ShaderReflection>> for ShaderReflection
sourceimpl From<ShaderReflection> for Rc<ID3D11ShaderReflection>
impl From<ShaderReflection> for Rc<ID3D11ShaderReflection>
sourcefn from(value: ShaderReflection) -> Self
fn from(value: ShaderReflection) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for ShaderReflection
impl !Send for ShaderReflection
impl !Sync for ShaderReflection
impl Unpin for ShaderReflection
impl UnwindSafe for ShaderReflection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more