Module thindx::d3d9

source · []
Expand description

[docs.microsoft.com] Direct3D 9 related types and APIs

Thin Direct3D9 wrappers for Rust, designed to be suitable for:

  • Greenfield projects targeting ancient APIs for some reason
  • Graphics middleware looking to integrate into existing D3D9 codebases

Interfaces

These are all refcounting COM smart pointers convertable to/from [mcom::Rc].

Unknown - The root type from which all sane COM types derive
  ├─ Direct3D[Ex] - Core factories for creating Device[Ex]s and SwapChain[Ex]s
  ├─ Device[Ex] - Create resources & dispatches rendering for an individual GPU
  ├─ SwapChain[Ex] - Manages swapping buffers for individual “views” (monitors/windows)
  ├─ Resource
  │ ├─ Surface - 2D buffer of pixels
  │ ├─ BaseTexture - A GPU-friendly collection of pixels
  │ │ ├─ CubeTexture - 6-sided 2D texture
  │ │ ├─ Texture - 2D texture
  │ │ └─ VolumeTexture - Dense 3D texture
  │ ├─ IndexBuffer - An index buffer indexes verticies in a VertexBuffer when rendering.
  │ └─ VertexBuffer - A vertex buffer typically contains points of a mesh to be rendered.
  ├─ Resource You’d expect these to be resources, but they aren’t - they derive from Unknown.
  │ ├─ Volume - 3D buffer of pixels
  │ ├─ PixelShader - per-fragment GPU program
  │ └─ VertexShader - per-vertex GPU program
  ├─ Query - An asyncronous GPU query for occlusion or other information.
  ├─ StateBlock - Used to capture/save and restore changes to Device state.
  └─ VertexDeclaration - Describes the layout of the contents of a VertexBuffer

Rust COM PointerC++ [Rust Ext Trait]Description
UnknownIUnknown[Ext]The root type from which all sane COM types derive
Direct3DIDirect3D9[Ext]Core factory for creating Devices
Direct3DExIDirect3D9Ex[Ext]Core factory for creating DeviceExs
DeviceIDirect3DDevice9[Ext]Create resources & dispatches rendering for an individual GPU
DeviceExIDirect3DDevice9Ex[Ext]Create resources & dispatches rendering for an individual GPU
SwapChainIDirect3DSwapChain9[Ext]Manages swapping buffers for individual monitors/windows
SwapChainExIDirect3DSwapChain9Ex[Ext]Manages swapping buffers for individual monitors/windows
ResourceIDirect3DResource9[Ext]Surface / *Texture / IndexBuffer / VertexBuffer
SurfaceIDirect3DSurface9[Ext]2D buffer of pixels
BaseTextureIDirect3DBaseTexture9[Ext]A GPU-friendly collection of pixels
CubeTextureIDirect3DCubeTexture9[Ext]6-sided 2D texture
TextureIDirect3DTexture9[Ext]2D texture
VolumeTextureIDirect3DVolumeTexture9[Ext]Dense 3D texture
IndexBufferIDirect3DIndexBuffer9[Ext]An index buffer indexes verticies in a VertexBuffer when rendering.
VertexBufferIDirect3DVertexBuffer9[Ext]A vertex buffer typically contains points of a mesh to be rendered.
VolumeIDirect3DVolume9[Ext]3D buffer of pixels
PixelShaderIDirect3DPixelShader9[Ext]per-fragment GPU program
VertexShaderIDirect3DVertexShader9[Ext]per-vertex GPU program
QueryIDirect3DQuery9[Ext]An asyncronous GPU query for occlusion or other information.
StateBlockIDirect3DStateBlock9[Ext]Used to capture/save and restore changes to Device state.
VertexDeclarationIDirect3DVertexDeclaration9[Ext]Describes the layout of the contents of a VertexBuffer

Enumerations

⚠️ NOTE: D3D enums are represented as Rust structs to avoid undefined behavior related to unlisted enumerants.

⚠️ NOTE: DeclMethod8, DeclType8, and DeclUsage8 are all 8-bit, despite enum D3DDECL* being 32-bit.
        ❌ This makes them unsuitable for raw function FFI, due to ABI mismatches.
        ✔️ This makes them suitable for VertexElement FFI, as D3DVERTEXELEMENT9::{Method,Type,and Usage} are all BYTEs.

RustC++Description
ErrorKind
D3D[ERR]::*
HRESULT
D3DERR_*
Windows HRESULTs optimized for displaying Direct3D errors
BackBufferType
BackBufferType::*
D3DBACKBUFFER_TYPE
D3DBACKBUFFER_TYPE_*
Mono, Left, or Right for stereo rendering
BasisType
Basis::*
D3DBASISTYPE
D3DBASIS_*
Tesselation basis
Blend
Blend::*
D3DBLEND
D3DBLEND_*
Target/output alpha/color blending factors
BlendOp
BlendOp::*
D3DBLENDOP
D3DBLENDOP_*
Target/output alpha/color blending operation
CmpFunc
Cmp::*
D3DCMPFUNC
D3DCMP_*
ZBuffer/depth comparison operation
ComposeRectsOp
ComposeRects::*
D3DCOMPOSERECTSOP
D3DCOMPOSERECTS_*
CubeMapFaces
CubeMapFace::*
D3DCUBEMAP_FACES
D3DCUBEMAP_FACE_*
Which face of a cubemap to lock/update/acquire/???
This isn’t a mask, CubeMapFace reads way better in all contexts!
Cull
Cull::*
D3DCULL
D3DCULL_*
None, CW, CCW
DebugMonitorTokens
DMT::*
D3DDEBUGMONITORTOKENS
D3DDMT_*
Debug monitor tokens.
DeclMethod8
DeclMethod8::*
D3DDECLMETHOD
D3DDECLMETHOD_*
Tesselation method.
DeclType8
DeclType8::*
D3DDECLTYPE
D3DDECLTYPE_*
Float1, Float2, … - Defines a vertex declaration data type.
DeclUsage8
DeclUsage8::*
D3DDECLUSAGE
D3DDECLUSAGE_*
Position, TexCoord, … - Defines the intended use of vertex data.
DegreeType
Degree::*
D3DDEGREETYPE
D3DDEGREE_*
Curve polynomial degree
DevType
DevType::*
D3DDEVTYPE
D3DDEVTYPE_*
Specifies what kind of Device should be created
DisplayRotation
DisplayRotation::*
D3DDISPLAYROTATION
D3DDISPLAYROTATION_*
Orientation of the monitor/display
FillMode
Fill::*
D3DFILLMODE
D3DFILL_*
Point, Wireframe, or Solid polygon rendering
FogMode
Fog::*
D3DFOGMODE
D3DFOG_*
None, Exp, Exp2, or Linear fog falloff
Format
Fmt::*
D3DFORMAT
D3DFMT_*
Texture and vertex element formats
LightType
LightType::*
D3DLIGHTTYPE
D3DLIGHT_*
Defines the type of a light (Point, Spot, or Directional)
MaterialColorSource
MCS::*
D3DMATERIALCOLORSOURCE
D3DMCS_*
Lighting material source
MultiSampleType
MultiSample::*
D3DMULTISAMPLE_TYPE
D3DMULTISAMPLE_*
Defines the levels of full-scene multisampling to apply
PatchEdgeStyle
PatchEdge::*
D3DPATCHEDGESTYLE
D3DPATCHEDGE_*
Discrete or Continuous tesselation.
Pool
Pool::*
D3DPOOL
D3DPOOL_*
Specifies what memory pool Resources should be stored in
PrimitiveType
PT::*
D3DPRIMITIVETYPE
D3DPT_*
Defines the primitives supported by Direct3D.
QueryType
QueryType::*
D3DQUERYTYPE
D3DQUERYTYPE_*
Identifies the query type.
RenderStateType
RS::*
D3DRENDERSTATETYPE
D3DRS_*
ResourceType
RType::*
D3DRESOURCETYPE
D3DRTYPE_*
Specifies the type of a Resource/Volume
SamplerStateType
Samp::*
D3DSAMPLERSTATETYPE
D3DSAMP_*
SamplerTextureType
STT::*
D3DSAMPLER_TEXTURE_TYPE
D3DSTT_*
ScanlineOrdering
ScanlineOrdering::*
D3DSCANLINEORDERING
D3DSCANLINEORDERING_*
SGR
SGR::*
D3DSGR
D3DSGR_*
Indicates whether gamma correction should be applied.
ShadeMode
Shade::*
D3DSHADEMODE
D3DSHADE_*
StateBlockType
SBT::*
D3DSTATEBLOCKTYPE
D3DSBT_*
Predefined sets of pipeline state used by state blocks
StencilOp
StencilOp::*
D3DSTENCILOP
D3DSTENCILOP_*
StreamSource
StreamSource::*
D3DSTREAMSOURCE
D3DSTREAMSOURCE_*
SwapEffect
SwapEffect::*
D3DSWAPEFFECT
D3DSWAPEFFECT_*
Defines IDirect3DDevice9Ext::present swap effects.
TextureAddress
TAddress::*
D3DTEXTUREADDRESS
D3DTADDRESS_*
TextureFilterType
TexF::*
D3DTEXTUREFILTERTYPE
D3DTEXF_*
TextureOp
TOP::*
D3DTEXTUREOP
D3DTOP_*
TextureStageStateType
TSS::*
D3DTEXTURESTAGESTATETYPE
D3DTSS_*
TransformStateType
TS::*
D3DTRANSFORMSTATETYPE
D3DTS_*
ZBufferType
ZB::*
D3DZBUFFERTYPE
D3DZB_*

Flags

RustC++Description
CreateD3DCREATE_*A combination of one or more flags that controls IDirect3D9Ext::create_device behavior.
FVFD3DFVF_*Describes the contents of vertices interleaved in a single data stream.
GetDataD3DGETDATA_*Controls how IDirect3DQuery9Ext::get_data_inplace behaves
IssueD3DISSUE_*Controls how IDirect3DQuery9Ext::issue behaves
LockD3DLOCK_*A combination of zero or more locking options that describe the type of lock to perform.
UsageD3DUSAGE_*Usage options that identify how resources are to be used.

Traits

RustC++Description
unsafe RawConversion trait for converting between thindx ⇄ [winapi]
unsafe SharedHandleParam*mut HANDLEPlaceholder for Sharing Resources *mut HANDLEs

Structures

RustC++Description
AdapterIdentifierD3DADAPTER_IDENTIFIER9Adapter metadata (driver, Description, driver version, vendor/device ids, …)
CapsD3DCAPS9Adapter/device capabilities and limitations
ClipStatusD3DCLIPSTATUS9Describes the current clip status.
ColorValueD3DCOLORVALUEA { r, g, b, a } floating-point color
DisplayModeD3DDISPLAYMODEA { width, height, refresh_rate, format } display mode
DisplayModeExD3DDISPLAYMODEEXA { width, height, refresh_rate, format, scanline_ordering } display mode
IndexBufferDescD3DINDEXBUFFER_DESCDescribes an IndexBuffer
LightD3DLIGHT9Describes lighting information
MaterialD3DMATERIAL9Describes a material that responds to lighting
PresentStatsD3DPRESENTSTATSDescribes swapchain statistics relating to PresentEx calls.
RasterStatusD3DRASTER_STATUS{ in_vblank, scan_line }
RectD3DRECT / RECT[0i32 .. 1i32, 2i32 .. 3i32] signed x/y range structure
VectorD3DVECTORA { x, y, z } 3-dimensional floating point position
VertexBufferDescD3DVERTEXBUFFER_DESCDescribes an VertexBuffer
VertexElementD3DVERTEXELEMENT9An element of a VertexDeclaration
ViewportD3DVIEWPORT9A { x, y, width, height, min_z, max_z } area to render into

Values

RustC++Description
bool32BOOL32-bit boolean type that’s ABI-compatible with Win32’s BOOL
ColorD3DCOLOR0xAARRGGBB style 32-bit color
LuidLUIDA 64-bit locally unique identifier
SdkVersionDWORDSpecify what Direct3D SDK to use (Direct3D[Ex]::create’s only parameter)

Wrappers

Wrapper typeUnderlying typeDescription
SafeDeviceDeviceDevice pointer + enough metadata to make more API calls safe

Features

featureDescription
9ex!defined(D3D_DISABLE_9EX) - Enables Direct3DEx, DeviceEx, SwapChainEx, etc.

Modules

[docs.microsoft.com] Direct3D PIX events for annotating graphics debugger traces and captures.

Structs

[docs.microsoft.com] D3DADAPTER_IDENTIFIER9

[docs.microsoft.com] D3DBACKBUFFER_TYPE

[docs.microsoft.com] D3DBASISTYPE

[docs.microsoft.com] D3DBOX / BOX

[docs.microsoft.com] D3DCMPFUNC

[docs.microsoft.com] D3DCOMPOSERECTSOP

[docs.microsoft.com] DWORD / D3DCREATE_*

[docs.microsoft.com] D3DCUBEMAP_FACES

[docs.microsoft.com] D3DCUBEMAP_FACES

[docs.microsoft.com] (extends BaseTexture) 6-faced 2D texture for use with cube mapping

Reference 6xTextureMipRefs to form cubemap dara for use with e.g. IDirect3DDevice9Ext::create_cube_texture_from.

[docs.microsoft.com] DWORD / D3DCURSOR_*

[docs.microsoft.com] D3DCURSORCAPS_*

[docs.microsoft.com] D3DDEBUGMONITORTOKENS

[docs.microsoft.com] D3DDEBUGMONITORTOKENS

[docs.microsoft.com] D3DDECLMETHOD, but 8 bit

[docs.microsoft.com] D3DDECLTYPE, but 8 bit

[docs.microsoft.com] D3DDECLUSAGE, but 8 bit

[docs.microsoft.com] D3DDEGREETYPE

[docs.microsoft.com] Core interface used for general rendering, resource creation, etc.

[docs.microsoft.com] D3DDEVICE_CREATION_PARAMETERS

[docs.microsoft.com] (extends Device) Core interface used for general rendering, resource creation, etc.

[docs.microsoft.com] Factory for use in creating your initial Device.

[docs.microsoft.com] (extends Direct3D) Factory for use in creating your initial DeviceEx.

[docs.microsoft.com] D3DDISPLAYMODEFILTER

[docs.microsoft.com] D3DDISPLAYROTATION

[docs.microsoft.com] DWORD / D3DFVF_*

[docs.microsoft.com] D3DFILLMODE

Similar to d3d::Format, but limited to texture-friendly formats, and adding metadata to allow safe + sound bounds.

[docs.microsoft.com] D3DFOGMODE

[docs.microsoft.com] DWORD / D3DGETDATA_*

[docs.microsoft.com] (extends Resource) An index buffer indexes verticies in a VertexBuffer when rendering.

[docs.microsoft.com] D3DINDEXBUFFER_DESC

[docs.microsoft.com] DWORD / D3DISSUE_*

[docs.microsoft.com] DWORD / D3DLOCK_*

[docs.microsoft.com] D3DMATERIALCOLORSOURCE

[docs.microsoft.com] D3DMATERIALCOLORSOURCE

[docs.microsoft.com] D3DMULTISAMPLE_TYPE

[docs.microsoft.com] D3DMULTISAMPLE_TYPE

[docs.microsoft.com] D3DPBLENDCAPS_*

[docs.microsoft.com] D3DPMISCCAPS_*

[docs.microsoft.com] D3DPRASTERCAPS_*

[docs.microsoft.com] D3DPSHADECAPS_*

[docs.microsoft.com] D3DPSHADERCAPS2_0

[docs.microsoft.com] D3DPRIMITIVETYPE

[docs.microsoft.com] D3DPTEXTURECAPS_*

[docs.microsoft.com] D3DPTFILTERCAPS_*

[docs.microsoft.com] D3DPTEXTURECAPS_*

[docs.microsoft.com] D3DPATCHEDGESTYLE

[docs.microsoft.com] A pixel/fragment shader is a GPU program, run on rasterized fragments.

[docs.microsoft.com] DWORD / D3DPRESENT_*

[docs.microsoft.com] DWORD / D3DPRESENTFLAG_*

[docs.microsoft.com] D3DPRESENT_PARAMETERS

[docs.microsoft.com] D3DRENDERSTATETYPE

[docs.microsoft.com] D3DRESOURCETYPE

[docs.microsoft.com] D3DRASTER_STATUS

[docs.microsoft.com] D3DRENDERSTATETYPE

[docs.microsoft.com] RGNDATA placeholder

[docs.microsoft.com] D3DSTATEBLOCKTYPE

[docs.microsoft.com] D3DSAMPLER_TEXTURE_TYPE

[docs.microsoft.com] Device + stored metadata allowing more APIs to be safe

[docs.microsoft.com] D3DSAMPLERSTATETYPE

[docs.microsoft.com] D3DSAMPLERSTATETYPE

[docs.microsoft.com] D3DSAMPLER_TEXTURE_TYPE

[docs.microsoft.com] D3DSCANLINEORDERING

[docs.microsoft.com] A D3D(9b)_SDK_VERSION for use with {IDirect3D9Ext, IDirect3D9ExExt}::create

[docs.microsoft.com] D3DSHADEMODE

PS_1_1 ..= PS_3_0, VS_1_1 ..= VS_3_0 (Direct3D 9 compatible shader versions)

[docs.microsoft.com] D3DSTENCILCAPS_*

[docs.microsoft.com] (extends Resource) A dense 2-dimensional region of data, often belonging to a Texture

[docs.microsoft.com] Manages swapping buffers for a view.

[docs.microsoft.com] (extends SwapChain) Adds more querying options.

[docs.microsoft.com] D3DTEXTUREADDRESS

[docs.microsoft.com] D3DTEXTUREOP

[docs.microsoft.com] D3DTRANSFORMSTATETYPE

[docs.microsoft.com] D3DTEXTURESTAGESTATETYPE

[docs.microsoft.com] D3DTEXTUREFILTERTYPE

[docs.microsoft.com] D3DTEXOPCAPS_*

[docs.microsoft.com] (extends BaseTexture) A dense 2-dimensional set of “pixels”

[docs.microsoft.com] D3DTEXTUREFILTERTYPE

Reference a 2-dimensional array of pixels for use with e.g. IDirect3DDevice9Ext::create_texture_from.

[docs.microsoft.com] D3DTEXTURESTAGESTATETYPE

[docs.microsoft.com] D3DTRANSFORMSTATETYPE

Similar to d3d::Format, but presumably limited to texture-friendly formats. Unlike FixedTextureFormat, there’s no guarantee that the values of this type are

[docs.microsoft.com] DWORD / D3DUSAGE_*

[docs.microsoft.com] D3DVSHADERCAPS2_0

[docs.microsoft.com] (extends Resource) A vertex buffer typically contains points of a mesh to be rendered.

[docs.microsoft.com] D3DVERTEXBUFFER_DESC

[docs.microsoft.com] Describes the layout of the contents of a VertexBuffer

[docs.microsoft.com] D3DVERTEXELEMENT9

[docs.microsoft.com] A vertex shader transforms mesh verticies when rendering.

[docs.microsoft.com] A dense 3-dimensional region of data, often belonging to a VolumeTexture

[docs.microsoft.com] (extends BaseTexture) A dense 3-dimensional set of “pixels”

Reference a 3-dimensional array of pixels for use with e.g. IDirect3DDevice9Ext::create_volume_texture_from.

[docs.microsoft.com] D3DZBUFFERTYPE

Enums

[docs.microsoft.com] D3DSAMPLERSTATETYPE + Value

[docs.microsoft.com] D3DSAMPLERSTATETYPE + Value

Traits

[docs.microsoft.com] IDirect3D9Ex extension methods

[docs.microsoft.com] IDirect3D9 extension methods

[docs.microsoft.com] IDirect3DBaseTexture9 extension methods

[docs.microsoft.com] IDirect3DCubeTexture9 extension methods

[docs.microsoft.com] IDirect3DDevice9Ex extension methods

[docs.microsoft.com] IDirect3DDevice9 extension methods

[docs.microsoft.com] IDirect3DIndexBuffer9 extension methods

[docs.microsoft.com] IDirect3DPixelShader9 extension methods

[docs.microsoft.com] IDirect3DQuery9 extension methods

[docs.microsoft.com] IDirect3DResource9 extension methods

[docs.microsoft.com] IDirect3DStateBlock9 extension methods

[docs.microsoft.com] IDirect3DSurface9 extension method list

[docs.microsoft.com] IDirect3DSwapChain9Ex extension methods

[docs.microsoft.com] IDirect3DSwapChain9 extension methods

[docs.microsoft.com] IDirect3DTexture9 extension methods

[docs.microsoft.com] IDirect3DVertexBuffer9 extension methods

[docs.microsoft.com] IDirect3DVertexDeclaration9 extension methods

[docs.microsoft.com] IDirect3DVertexShader9 extension methods

[docs.microsoft.com] IDirect3DVolume9 extension methods

[docs.microsoft.com] IDirect3DVolumeTexture9 extension methods

u16 or u32 - an index type safe for use with Direct3D 9

0xAARRGGBB, [0xAA, 0xRR, 0xGG, 0xBB], or (0xAA, 0xRR, 0xGG, 0xBB)

Functions