ID3DX10ThreadPump interface
Used to execute tasks asynchronously, and created with D3DX10CreateThreadPump. There are several D3DX10 APIs that can optionally take a thread pump as a parameter, such as D3DX10CreateTextureFromFile and D3DX10CompileFromFile (see remarks for complete list). If the thread pump is passed into these APIs, they will execute asynchronously on a separate thread pump thread. The advantage to doing this is that it can make loading and processing large amounts of data happen without seeing a noticable slow down in performance on screen.
Members
The ID3DX10ThreadPump interface inherits from the IUnknown interface. ID3DX10ThreadPump also has these types of members:
Methods
The ID3DX10ThreadPump interface has these methods.
Method | Description |
---|---|
AddWorkItem | Add a work item to the thread pump. |
GetQueueStatus | Get the number of items in each of the three queues inside the thread pump. |
GetWorkItemCount | Get the number of work items currently in the thread pump. |
ProcessDeviceWorkItems | Set work items to the device after they have finished loading and processing. When the thread pump has finished loading and processing a resource or shader, it will hold it in a queue until this API is called, at which point the processed items will be set to the device. This is useful for controlling the amount of processing that is spent on binding resources to the device for each frame. See remarks. |
PurgeAllItems | Clear all work items from the thread pump. |
WaitForAllItems | Wait for all work items in the thread pump to finish. |
Remarks
The thread pump loads and processes data in a 3 step process. It goes:
- Load and decompress the data with a Data Loader. The data loader object has three methods that the thread pump will call internally as it is loading and decompressing the data: ID3DX10DataLoader::Load, ID3DX10DataLoader::Decompress, and ID3DX10DataLoader::Destroy. The specific functionality of these three APIs differs depending on the type of data being loaded and decompressed. The data loader interface can also be inherited and its APIs can be changed if one is loading a data file defined in one's own custom format.
- Process the data with a Data Processor. The data processor object has three methods that the thread pump will call internally as it is processing the data: ID3DX10DataProcessor::Process, ID3DX10DataProcessor::CreateDeviceObject, and ID3DX10DataProcessor::Destroy. The way it processes the data will be different depending on the type of data. For example, if the data is a texture stored as a JPEG, then ID3DX10DataProcessor::Process will do JPEG decompression to get the image's raw image bits. If the data is a shader, then ID3DX10DataProcessor::Process will compile the HLSL into bytecode. After the data has been processed a device object will be created for that data (with ID3DX10DataProcessor::CreateDeviceObject) and the object will be added to a queue of device objects. The data processor interface can also be inherited and its APIs can be changed if one is processing a data file defined in one's own custom format.
- Bind the device object to the device. This is done when one's application calls ID3DX10ThreadPump::ProcessDeviceWorkItems, which will bind a specified number of objects in the queue of device objects to the device.
The thread pump can be used to load data in one of two ways: by calling an API that takes a thread pump as a parameter, such as D3DX10CreateTextureFromFile and D3DX10CompileFromFile, or by calling ID3DX10ThreadPump::AddWorkItem. In the case of the APIs that take a thread pump, the data loader and data processor are created internally. In the case of AddWorkItem, the data loader and data processor must be created beforehand and are then passed into AddWorkItem. D3DX10 provides a set of APIs for creating data loaders and data processors that have functionality for loading and processing common data formats (see remarks for complete list of APIs). For custom data formats, the data loader and data processor interfaces must be inherited and their methods must be redefined.
The thread pump object takes up a substantial amount of resources, so generally only one should be created per application.
Built-in D3DX10 data loaders
Description | |
---|---|
D3DX10CreateAsyncFileLoader | Create a file loader asynchronously. |
D3DX10CreateAsyncMemoryLoader | Create a data loader asynchronously. |
D3DX10CreateAsyncResourceLoader | Create a resource loader asynchronously. |
Built-in D3DX10 data processors
Description | |
---|---|
D3DX10CreateAsyncTextureProcessor | Create a data processor to be used with a thread pump. This API is similar to D3DX10CreateAsyncTextureInfoProcessor but it also loads the texture. |
D3DX10CreateAsyncTextureInfoProcessor | Create a data processor to be used with a thread pump. |
D3DX10CreateAsyncShaderCompilerProcessor | Compile a shader and create a data processor asynchronously. |
D3DX10CreateAsyncEffectCompilerProcessor | Create an effect with a data processor asynchronously. |
D3DX10CreateAsyncEffectCreateProcessor | Create an effect pool asynchronously. |
D3DX10CreateAsyncEffectPoolCreateProcessor | Create a data processor asynchronously. |
D3DX10CreateAsyncShaderPreprocessProcessor | Create a data processor for a shader asynchronously. |
APIs that take a thread pump as a parameter.
Description | |
---|---|
D3DX10CompileFromFile | Compile a shader from a file. |
D3DX10CompileFromMemory | Compile a shader residing in memory. |
D3DX10CompileFromResource | Compile a shader from a resource. |
D3DX10CreateEffectFromFile | Create an effect from a file. |
D3DX10CreateEffectFromMemory | Create an effect from memory. |
D3DX10CreateEffectFromResource | Create an effect from a resource. |
D3DX10CreateEffectPoolFromFile | Create an effect pool from a file. |
D3DX10CreateEffectPoolFromMemory | Create an effect pool from a file residing in memory. |
D3DX10CreateEffectPoolFromResource | Create an effect pool from a resource. |
D3DX10PreprocessShaderFromFile | Create a shader from a file without compiling it. |
D3DX10PreprocessShaderFromMemory | Create a shader from memory without compiling it. |
D3DX10PreprocessShaderFromResource | Create a shader from a resource without compiling it. |
D3DX10CreateShaderResourceViewFromFile | Create a shader-resource view from a file. |
D3DX10CreateShaderResourceViewFromMemory | Create a shader-resource view from a file in memory. |
D3DX10CreateShaderResourceViewFromResource | Create a shader-resource view from a resource. |
D3DX10GetImageInfoFromFile | Retrieves information about a given image file. |
D3DX10GetImageInfoFromMemory | Get information about an image already loaded into memory. |
D3DX10GetImageInfoFromResource | Retrieves information about a given image in a resource. |
D3DX10CreateTextureFromFile | Create a texture resource from a file. |
D3DX10CreateTextureFromMemory | Create a texture resource from a file residing in system memory. |
D3DX10CreateTextureFromResource | Create a texture resource from another resource. |
Requirements
Requirement | Value |
---|---|
Header |
|
Library |
|
See also