#[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

[docs.microsoft.com] ID3D11ShaderReflection::GetBitwiseInstructionCount

Gets the number of bitwise instructions.

Example
let count = vs.get_bitwise_instruction_count();

[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());

[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());

[docs.microsoft.com] ID3D11ShaderReflection::GetConversionInstructionCount

Gets the number of conversion instructions.

Example
let count : u32 = vs.get_conversion_instruction_count();

[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);

[docs.microsoft.com] ID3D11ShaderReflection::GetGSInputPrimitive

Gets the geometry-shader input-primitive description.

Returns
Example
assert_eq!(vs.get_gs_input_primitive(), d3d::Primitive::Undefined);

[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));

[docs.microsoft.com] ID3D11ShaderReflection::GetMinFeatureLevel

Gets the minimum feature level.

Errors
  • …?
Example
assert_eq!(vs.get_min_feature_level().unwrap(), d3d::FeatureLevel::_10_0);

[docs.microsoft.com] ID3D11ShaderReflection::GetMovcInstructionCount

Gets the number of Movc instructions.

Example
let count = vs.get_movc_instruction_count();

[docs.microsoft.com] ID3D11ShaderReflection::GetMovInstructionCount

Gets the number of Mov instructions.

Example
let count : u32 = vs.get_mov_instruction_count();

[docs.microsoft.com] ID3D11ShaderReflection::GetNumInterfaceSlots

Gets the number of interface slots in a shader.

Example
let slots : u32 = vs.get_num_interface_slots();

[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));

[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));

[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);

[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));

[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(""));

[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));

[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());

[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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

The raw underlying winapi type

Take ownership from a raw winapi type, panicing if raw is null. Read more

Take ownership from a raw winapi type, returning None if raw is null. Read more

Give up / leak ownership into a raw winapi pointer type.

Allow access as a raw winapi pointer type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.