1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
use crate::*;
use crate::ctypes::*;
use winapi::shared::winerror::*;
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nn-d3d11shader-id3d11moduleinstance)\]
/// ID3D11ModuleInstance
///
/// A module-instance interface is used for resource rebinding.
#[derive(Clone)] #[repr(transparent)]
pub struct ModuleInstance(pub(crate) mcom::Rc<winapi::um::d3d11shader::ID3D11ModuleInstance>);
convert!(unsafe ModuleInstance => Unknown, winapi::um::d3d11shader::ID3D11ModuleInstance);
fn check(method: &'static str, hr: HRESULT) -> Result<bool, MethodError> {
if hr == S_FALSE {
Ok(false)
} else {
MethodError::check(method, hr)?;
Ok(true)
}
}
impl ModuleInstance {
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindconstantbuffer)\]
/// ID3D11ModuleInstance::BindConstantBuffer
///
/// Rebinds a constant buffer from a source slot to a destination slot.
///
/// ### Arguments
/// * `src_slot` - The source slot number for rebinding.
/// * `dst_slot` - The destination slot number for rebinding.
/// * `dst_offset` - The offset in bytes of the destination slot for rebinding. The offset must have 16-byte alignment.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - `dst_slot` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * Ok(`true`) - for a valid rebinding
/// * Ok(`false`) - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_constant_buffer(&self, src_slot: u32, dst_slot: u32, dst_offset: u32) -> Result<bool, MethodError> {
let hr = unsafe { self.0.BindConstantBuffer(src_slot, dst_slot, dst_offset) };
check("ID3D11ModuleInstance::BindConstantBuffer", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindconstantbufferbyname)\]
/// ID3D11ModuleInstance::BindConstantBufferByName
///
/// Rebinds a constant buffer by name to a destination slot.
///
/// ### Arguments
/// * `name` - The name of the constant buffer for rebinding.
/// * `dst_slot` - The destination slot number for rebinding.
/// * `dst_offset` - The offset in bytes of the destination slot for rebinding. The offset must have 16-byte alignment.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - `dst_slot` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_constant_buffer_by_name(&self, name: impl TryIntoAsCStr, dst_slot: u32, dst_offset: u32) -> Result<bool, MethodError> {
let name = name.try_into().map_err(|e| MethodError::new("ID3D11ModuleInstance::BindConstantBufferByName", e))?;
let hr = unsafe { self.0.BindConstantBufferByName(name.as_cstr(), dst_slot, dst_offset) };
check("ID3D11ModuleInstance::BindConstantBufferByName", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindresource)\]
/// ID3D11ModuleInstance::BindResource
///
/// Rebinds a texture or buffer from source slot to destination slot.
///
/// ### Arguments
/// * `src_slot` - The first source slot number for rebinding.
/// * `dst_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_slot .. dst_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_resource(&self, src_slot: u32, dst_slot: u32, count: u32) -> Result<bool, MethodError> {
let hr = unsafe { self.0.BindResource(src_slot, dst_slot, count) };
check("ID3D11ModuleInstance::BindResource", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindresourceasunorderedaccessview)\]
/// ID3D11ModuleInstance::BindResourceAsUnorderedAccessView
///
/// Rebinds a resource as an unordered access view (UAV) from source slot to destination slot.
///
/// ### Arguments
/// * `src_srv_slot` - The first source slot number for rebinding.
/// * `dst_uav_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_uav_slot .. dst_uav_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_resource_as_unordered_access_view(&self, src_srv_slot: u32, dst_uav_slot: u32, count: u32) -> Result<bool, MethodError> {
let hr = unsafe { self.0.BindResourceAsUnorderedAccessView(src_srv_slot, dst_uav_slot, count) };
check("ID3D11ModuleInstance::BindResourceAsUnorderedAccessView", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindresourceasunorderedaccessviewbyname)\]
/// ID3D11ModuleInstance::BindResourceAsUnorderedAccessViewByName
///
/// Rebinds a resource by name as an unordered access view (UAV) to destination slots.
///
/// ### Arguments
/// * `srv_name` - The name of the resource for rebinding.
/// * `dst_uav_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_uav_slot .. dst_uav_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_resource_as_unordered_access_view_by_name(&self, srv_name: impl TryIntoAsCStr, dst_uav_slot: u32, count: u32) -> Result<bool, MethodError> {
let srv_name = srv_name.try_into().map_err(|e| MethodError::new("ID3D11ModuleInstance::BindResourceAsUnorderedAccessViewByName", e))?;
let hr = unsafe { self.0.BindResourceAsUnorderedAccessViewByName(srv_name.as_cstr(), dst_uav_slot, count) };
check("ID3D11ModuleInstance::BindResourceAsUnorderedAccessViewByName", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindresourcebyname)\]
/// ID3D11ModuleInstance::BindResourceByName
///
/// Rebinds a texture or buffer by name to destination slots.
///
/// ### Arguments
/// * `name` - The name of the texture or buffer for rebinding.
/// * `dst_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_slot .. dst_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_resource_by_name(&self, name: impl TryIntoAsCStr, dst_slot: u32, count: u32) -> Result<bool, MethodError> {
let name = name.try_into().map_err(|e| MethodError::new("ID3D11ModuleInstance::BindResourceByName", e))?;
let hr = unsafe { self.0.BindResourceByName(name.as_cstr(), dst_slot, count) };
check("ID3D11ModuleInstance::BindResourceByName", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindsampler)\]
/// ID3D11ModuleInstance::BindSampler
///
/// Rebinds a sampler from source slot to destination slot.
///
/// ### Arguments
/// * `src_slot` - The first source slot number for rebinding.
/// * `dst_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_slot .. dst_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_sampler(&self, src_slot: u32, dst_slot: u32, count: u32) -> Result<bool, MethodError> {
let hr = unsafe { self.0.BindSampler(src_slot, dst_slot, count) };
check("ID3D11ModuleInstance::BindSampler", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindsamplerbyname)\]
/// ID3D11ModuleInstance::BindSamplerByName
///
/// Rebinds a sampler by name to destination slots.
///
/// ### Arguments
/// * `name` - The name of the sampler for rebinding.
/// * `dst_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_slot .. dst_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_sampler_by_name(&self, name: impl TryIntoAsCStr, dst_slot: u32, count: u32) -> Result<bool, MethodError> {
let name = name.try_into().map_err(|e| MethodError::new("ID3D11ModuleInstance::BindSamplerByName", e))?;
let hr = unsafe { self.0.BindSamplerByName(name.as_cstr(), dst_slot, count) };
check("ID3D11ModuleInstance::BindSamplerByName", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindunorderedaccessview)\]
/// ID3D11ModuleInstance::BindUnorderedAccessView
///
/// Rebinds an unordered access view (UAV) from source slot to destination slot.
///
/// ### Arguments
/// * `src_slot` - The first source slot number for rebinding.
/// * `dst_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_slot .. dst_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_unordered_access_view(&self, src_slot: u32, dst_slot: u32, count: u32) -> Result<bool, MethodError> {
let hr = unsafe { self.0.BindUnorderedAccessView(src_slot, dst_slot, count) };
check("ID3D11ModuleInstance::BindUnorderedAccessView", hr)
}
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/d3d11shader/nf-d3d11shader-id3d11moduleinstance-bindunorderedaccessviewbyname)\]
/// ID3D11ModuleInstance::BindUnorderedAccessViewByName
///
/// Rebinds an unordered access view (UAV) by name to destination slots.
///
/// ### Arguments
/// * `name` - The name of the UAV for rebinding.
/// * `dst_slot` - The first destination slot number for rebinding.
/// * `count` - The number of slots for rebinding.
///
/// ### Errors
/// * [E::FAIL] - the rebinding is out-of-bounds
/// * [E::FAIL] - A slot between `dst_slot .. dst_slot + count` was already bound?
/// * [E::FAIL] - an otherwise invalid rebinding
///
/// ### Returns
/// * `true` - for a valid rebinding
/// * `false` - for rebinding a nonexistent slot; that is, for which the shader reflection doesn’t have any data
///
/// ### Example
/// ```rust
/// # use thindx::*;
/// // TODO
/// ```
pub fn bind_unordered_access_view_by_name(&self, name: impl TryIntoAsCStr, dst_slot: u32, count: u32) -> Result<bool, MethodError> {
let name = name.try_into().map_err(|e| MethodError::new("ID3D11ModuleInstance::BindUnorderedAccessViewByName", e))?;
let hr = unsafe { self.0.BindUnorderedAccessViewByName(name.as_cstr(), dst_slot, count) };
check("ID3D11ModuleInstance::BindUnorderedAccessViewByName", hr)
}
}