ReShade
A generic post-processing injector for games and video software.
Public Member Functions | List of all members
reshade::api::device Struct Referenceabstract

A logical render device, used for resource creation and global operations. More...

#include <reshade_api_device.hpp>

Inheritance diagram for reshade::api::device:
reshade::api::api_object

Public Member Functions

virtual device_api get_api () const =0
 Gets the underlying render API used by this device. More...
 
virtual bool check_capability (device_caps capability) const =0
 Checks whether the device supports the specified capability . More...
 
virtual bool check_format_support (format format, resource_usage usage) const =0
 Checks whether the specified texture format supports the specified usage . More...
 
virtual bool create_sampler (const sampler_desc &desc, sampler *out_handle)=0
 Creates a new sampler state object. More...
 
virtual void destroy_sampler (sampler handle)=0
 Instantly destroys a sampler that was previously created via create_sampler. More...
 
virtual bool create_resource (const resource_desc &desc, const subresource_data *initial_data, resource_usage initial_state, resource *out_handle, void **shared_handle=nullptr)=0
 Allocates and creates a new resource. More...
 
virtual void destroy_resource (resource handle)=0
 Instantly destroys a resource that was previously created via create_resource and frees its memory. Make sure the resource is no longer in use on the GPU (via any command list that may reference it and is still being executed) before doing this and never try to destroy resources created by the application! More...
 
virtual resource_desc get_resource_desc (resource resource) const =0
 Gets the description of the specified resource. More...
 
virtual bool create_resource_view (resource resource, resource_usage usage_type, const resource_view_desc &desc, resource_view *out_handle)=0
 Creates a new resource view for the specified resource . More...
 
virtual void destroy_resource_view (resource_view handle)=0
 Instantly destroys a resource view that was previously created via create_resource_view. More...
 
virtual resource get_resource_from_view (resource_view view) const =0
 Gets the handle to the underlying resource the specified resource view was created for. More...
 
virtual resource_view_desc get_resource_view_desc (resource_view view) const =0
 Gets the description of the specified resource view. More...
 
virtual bool map_buffer_region (resource resource, uint64_t offset, uint64_t size, map_access access, void **out_data)=0
 Maps the memory of a buffer resource into application address space. More...
 
virtual void unmap_buffer_region (resource resource)=0
 Unmaps a previously mapped buffer resource. More...
 
virtual bool map_texture_region (resource resource, uint32_t subresource, const subresource_box *box, map_access access, subresource_data *out_data)=0
 Maps the memory of a texture resource into application address space. More...
 
virtual void unmap_texture_region (resource resource, uint32_t subresource)=0
 Unmaps a previously mapped texture resource. More...
 
virtual void update_buffer_region (const void *data, resource resource, uint64_t offset, uint64_t size)=0
 Uploads data to a buffer resource. More...
 
virtual void update_texture_region (const subresource_data &data, resource resource, uint32_t subresource, const subresource_box *box=nullptr)=0
 Uploads data to a texture resource. More...
 
virtual bool create_pipeline (pipeline_layout layout, uint32_t subobject_count, const pipeline_subobject *subobjects, pipeline *out_handle)=0
 Creates a new pipeline state object. More...
 
virtual void destroy_pipeline (pipeline handle)=0
 Instantly destroys a pipeline state object that was previously created via create_pipeline. More...
 
virtual bool create_pipeline_layout (uint32_t param_count, const pipeline_layout_param *params, pipeline_layout *out_handle)=0
 Creates a new pipeline layout. More...
 
virtual void destroy_pipeline_layout (pipeline_layout handle)=0
 Instantly destroys a pipeline layout that was previously created via create_pipeline_layout. More...
 
bool allocate_descriptor_set (pipeline_layout layout, uint32_t param, descriptor_set *out_handle)
 Allocates a descriptor set from an internal pool. More...
 
virtual bool allocate_descriptor_sets (uint32_t count, pipeline_layout layout, uint32_t param, descriptor_set *out_handles)=0
 Allocates one or more descriptor sets from an internal pool. More...
 
void free_descriptor_set (descriptor_set handle)
 Frees adescriptor set that was previously allocated via create_descriptor_set. More...
 
virtual void free_descriptor_sets (uint32_t count, const descriptor_set *handles)=0
 Frees one or more descriptor sets that were previously allocated via create_descriptor_sets. More...
 
virtual void get_descriptor_pool_offset (descriptor_set set, uint32_t binding, uint32_t array_offset, descriptor_pool *out_pool, uint32_t *out_offset) const =0
 Gets the offset (in descriptors) of the specified binding in the underlying descriptor pool. More...
 
void copy_descriptors (const descriptor_set_copy &copy)
 Copies the contents of a descriptor set to another descriptor set. More...
 
virtual void copy_descriptor_sets (uint32_t count, const descriptor_set_copy *copies)=0
 Copies the contents between multiple descriptor sets. More...
 
void update_descriptors (const descriptor_set_update &update)
 Updates the contents of a descriptor set with the specified descriptors. More...
 
virtual void update_descriptor_sets (uint32_t count, const descriptor_set_update *updates)=0
 Updates the contents of multiple descriptor sets with the specified descriptors. More...
 
virtual bool create_query_pool (query_type type, uint32_t size, query_pool *out_handle)=0
 Creates a new query pool. More...
 
virtual void destroy_query_pool (query_pool handle)=0
 Instantly destroys a query pool that was previously created via create_query_pool. More...
 
virtual bool get_query_pool_results (query_pool pool, uint32_t first, uint32_t count, void *results, uint32_t stride)=0
 Gets the results of queries in a query pool. More...
 
virtual void set_resource_name (resource handle, const char *name)=0
 Associates a name with a resource, for easier debugging in external tools. More...
 
virtual void set_resource_view_name (resource_view handle, const char *name)=0
 Associates a name with a resource view, for easier debugging in external tools. More...
 
- Public Member Functions inherited from reshade::api::api_object
virtual uint64_t get_native () const =0
 Gets the underlying native object for this API object. More...
 
virtual void get_private_data (const uint8_t guid[16], uint64_t *data) const =0
 Gets a user-defined 64-bit value from the object that was previously set via set_private_data, or zero if none associated with the specified guid exists. More...
 
virtual void set_private_data (const uint8_t guid[16], const uint64_t data)=0
 Stores a user-defined 64-bit value in the object and associates it with the specified guid . More...
 
template<typename T >
T & get_private_data () const
 Gets a reference to user-defined data from the object that was previously allocated via create_private_data. More...
 
template<typename T >
T & create_private_data ()
 Allocates user-defined data and stores it in the object. More...
 
template<typename T >
void destroy_private_data ()
 Frees user-defined data that was previously allocated via create_private_data. More...
 

Detailed Description

A logical render device, used for resource creation and global operations.

Functionally equivalent to a 'IDirect3DDevice9', 'ID3D10Device', 'ID3D11Device', 'ID3D12Device', 'HGLRC' or 'VkDevice'.

This class is safe to use concurrently from multiple threads in D3D10+ and Vulkan.

Member Function Documentation

◆ allocate_descriptor_set()

bool reshade::api::device::allocate_descriptor_set ( pipeline_layout  layout,
uint32_t  param,
descriptor_set out_handle 
)
inline

Allocates a descriptor set from an internal pool.

Parameters
layoutPipeline layout that contains a parameter that describes the descriptor set.
paramIndex of the pipeline layout parameter that describes the descriptor set.
out_handlePointer to a a variable that is set to the handles of the created descriptor set.
Returns
true if the descriptor set was successfully created, false otherwise (in this case out_handle is set to zeroe).

◆ allocate_descriptor_sets()

virtual bool reshade::api::device::allocate_descriptor_sets ( uint32_t  count,
pipeline_layout  layout,
uint32_t  param,
descriptor_set out_handles 
)
pure virtual

Allocates one or more descriptor sets from an internal pool.

Parameters
countNumber of descriptor sets to allocate.
layoutPipeline layout that contains a parameter that describes the descriptor set.
paramIndex of the pipeline layout parameter that describes the descriptor set.
out_handlesPointer to an array of handles with at least count elements that is filled with the handles of the created descriptor sets.
Returns
true if the descriptor sets were successfully created, false otherwise (in this case out_handles is filled with zeroes).

◆ check_capability()

virtual bool reshade::api::device::check_capability ( device_caps  capability) const
pure virtual

Checks whether the device supports the specified capability .

◆ check_format_support()

virtual bool reshade::api::device::check_format_support ( format  format,
resource_usage  usage 
) const
pure virtual

Checks whether the specified texture format supports the specified usage .

◆ copy_descriptor_sets()

virtual void reshade::api::device::copy_descriptor_sets ( uint32_t  count,
const descriptor_set_copy copies 
)
pure virtual

Copies the contents between multiple descriptor sets.

Parameters
countNumber of copies to process.
copiesPointer to an array of descriptor set copies to process.

◆ copy_descriptors()

void reshade::api::device::copy_descriptors ( const descriptor_set_copy copy)
inline

Copies the contents of a descriptor set to another descriptor set.

Parameters
copyDescriptor set copy to process.

◆ create_pipeline()

virtual bool reshade::api::device::create_pipeline ( pipeline_layout  layout,
uint32_t  subobject_count,
const pipeline_subobject subobjects,
pipeline out_handle 
)
pure virtual

Creates a new pipeline state object.

Parameters
layoutPipeline layout to use.
subobject_countNumber of sub-objects.
subobjectsPointer to an array of sub-objects that describe this pipeline.
out_handlePointer to a variable that is set to the handle of the created pipeline state object.
Returns
true if the pipeline state object was successfully created, false otherwise (in this case out_handle is set to zero).

◆ create_pipeline_layout()

virtual bool reshade::api::device::create_pipeline_layout ( uint32_t  param_count,
const pipeline_layout_param params,
pipeline_layout out_handle 
)
pure virtual

Creates a new pipeline layout.

Parameters
param_countNumber of layout parameters.
paramsPointer to an array of layout parameters that describe this pipeline layout.
out_handlePointer to a variable that is set to the handle of the created pipeline layout.
Returns
true if the pipeline layout was successfully created, false otherwise (in this case out_handle is set to zero).

◆ create_query_pool()

virtual bool reshade::api::device::create_query_pool ( query_type  type,
uint32_t  size,
query_pool out_handle 
)
pure virtual

Creates a new query pool.

Parameters
typeType of queries that will be used with this pool.
sizeNumber of queries to allocate in the pool.
out_handlePointer to a variable that is set to the handle of the created query pool.
Returns
true if the query pool was successfully created, false otherwise (in this case out_handle is set to zero).

◆ create_resource()

virtual bool reshade::api::device::create_resource ( const resource_desc desc,
const subresource_data initial_data,
resource_usage  initial_state,
resource out_handle,
void **  shared_handle = nullptr 
)
pure virtual

Allocates and creates a new resource.

Parameters
descDescription of the resource to create.
initial_dataOptional data to upload to the resource after creation. This should point to an array of mapped_subresource, one for each subresource (mipmap levels and array layers). Can be nullptr to indicate no initial data to upload.
initial_stateInitial state of the resource after creation. This can later be changed via command_list::barrier.
out_handlePointer to a variable that is set to the handle of the created resource.
shared_handleOptional pointer to a variable of type HANDLE used when resource_desc::flags contains resource_flags::shared. When that variable is a nullptr, it is set to the exported shared handle of the created resource. When that variable is a valid handle, the resource is imported from that shared handle.
Returns
true if the resource was successfully created, false otherwise (in this case out_handle is set to zero).

◆ create_resource_view()

virtual bool reshade::api::device::create_resource_view ( resource  resource,
resource_usage  usage_type,
const resource_view_desc desc,
resource_view out_handle 
)
pure virtual

Creates a new resource view for the specified resource .

Parameters
resourceResource to create the view to.
usage_typeUsage type of the resource view to create. Set to resource_usage::shader_resource to create a shader resource view, resource_usage::depth_stencil for a depth-stencil view, resource_usage::render_target for a render target etc.
descDescription of the resource view to create.
out_handlePointer to a variable that is set to the handle of the created resource view.
Returns
true if the resource view was successfully created, false otherwise (in this case out_handle is set to zero).

◆ create_sampler()

virtual bool reshade::api::device::create_sampler ( const sampler_desc desc,
sampler out_handle 
)
pure virtual

Creates a new sampler state object.

Parameters
descDescription of the sampler to create.
out_handlePointer to a variable that is set to the handle of the created sampler.
Returns
true if the sampler was successfully created, false otherwise (in this case out_handle is set to zero).

◆ destroy_pipeline()

virtual void reshade::api::device::destroy_pipeline ( pipeline  handle)
pure virtual

Instantly destroys a pipeline state object that was previously created via create_pipeline.

◆ destroy_pipeline_layout()

virtual void reshade::api::device::destroy_pipeline_layout ( pipeline_layout  handle)
pure virtual

Instantly destroys a pipeline layout that was previously created via create_pipeline_layout.

◆ destroy_query_pool()

virtual void reshade::api::device::destroy_query_pool ( query_pool  handle)
pure virtual

Instantly destroys a query pool that was previously created via create_query_pool.

◆ destroy_resource()

virtual void reshade::api::device::destroy_resource ( resource  handle)
pure virtual

Instantly destroys a resource that was previously created via create_resource and frees its memory. Make sure the resource is no longer in use on the GPU (via any command list that may reference it and is still being executed) before doing this and never try to destroy resources created by the application!

◆ destroy_resource_view()

virtual void reshade::api::device::destroy_resource_view ( resource_view  handle)
pure virtual

Instantly destroys a resource view that was previously created via create_resource_view.

◆ destroy_sampler()

virtual void reshade::api::device::destroy_sampler ( sampler  handle)
pure virtual

Instantly destroys a sampler that was previously created via create_sampler.

◆ free_descriptor_set()

void reshade::api::device::free_descriptor_set ( descriptor_set  handle)
inline

Frees adescriptor set that was previously allocated via create_descriptor_set.

◆ free_descriptor_sets()

virtual void reshade::api::device::free_descriptor_sets ( uint32_t  count,
const descriptor_set handles 
)
pure virtual

Frees one or more descriptor sets that were previously allocated via create_descriptor_sets.

◆ get_api()

virtual device_api reshade::api::device::get_api ( ) const
pure virtual

Gets the underlying render API used by this device.

◆ get_descriptor_pool_offset()

virtual void reshade::api::device::get_descriptor_pool_offset ( descriptor_set  set,
uint32_t  binding,
uint32_t  array_offset,
descriptor_pool out_pool,
uint32_t *  out_offset 
) const
pure virtual

Gets the offset (in descriptors) of the specified binding in the underlying descriptor pool.

Parameters
setDescriptor set to get the offset from.
bindingBinding in the descriptor set to get the offset from.
array_offsetArray index in the specified binding .
out_poolPointer to a variable that is set to the handle of the underlying descriptor pool the set was allocated from.
out_offsetPointer to a variable that is set to the offset of the descriptor set in the underlying pool.

◆ get_query_pool_results()

virtual bool reshade::api::device::get_query_pool_results ( query_pool  pool,
uint32_t  first,
uint32_t  count,
void *  results,
uint32_t  stride 
)
pure virtual

Gets the results of queries in a query pool.

Parameters
poolQuery pool that contains the queries.
firstIndex of the first query in the pool to copy the results from.
countNumber of query results to copy.
resultsPointer to an array that is filled with the results.
strideSize (in bytes) of each element in the results array.
Returns
true if the query results were successfully downloaded from the GPU, false otherwise.

◆ get_resource_desc()

virtual resource_desc reshade::api::device::get_resource_desc ( resource  resource) const
pure virtual

Gets the description of the specified resource.

◆ get_resource_from_view()

virtual resource reshade::api::device::get_resource_from_view ( resource_view  view) const
pure virtual

Gets the handle to the underlying resource the specified resource view was created for.

◆ get_resource_view_desc()

virtual resource_view_desc reshade::api::device::get_resource_view_desc ( resource_view  view) const
pure virtual

Gets the description of the specified resource view.

◆ map_buffer_region()

virtual bool reshade::api::device::map_buffer_region ( resource  resource,
uint64_t  offset,
uint64_t  size,
map_access  access,
void **  out_data 
)
pure virtual

Maps the memory of a buffer resource into application address space.

Parameters
resourceBuffer resource to map to host memory.
offsetOffset (in bytes) into the buffer resource to start mapping.
sizeNumber of bytes to map. Set to -1 (UINT64_MAX) to indicate that the entire buffer should be mapped.
accessHint on how the returned data pointer will be accessed.
out_dataPointer to a variable that is set to a pointer to the memory of the buffer resource.
Returns
true if the memory of the buffer resource was successfully mapped, false otherwise (in this case out_data is set to nullptr).

◆ map_texture_region()

virtual bool reshade::api::device::map_texture_region ( resource  resource,
uint32_t  subresource,
const subresource_box box,
map_access  access,
subresource_data out_data 
)
pure virtual

Maps the memory of a texture resource into application address space.

Parameters
resourceTexture resource to map to host memory.
subresourceIndex of the subresource to map (level + (layer * levels)).
boxOptional 3D box (or nullptr to reference the entire subresource) that defines the region in the resource to map.
accessHint on how the returned data pointer will be accessed.
out_dataPointer to a variable that is set to a pointer to the memory of the texture resource and optionally the row and slice pitch of that data (depending on the resource type).
Returns
true if the memory of the texture resource was successfully mapped, false otherwise (in this case out_data is set to nullptr).

◆ set_resource_name()

virtual void reshade::api::device::set_resource_name ( resource  handle,
const char *  name 
)
pure virtual

Associates a name with a resource, for easier debugging in external tools.

Parameters
handleResource to associate a name with.
nameNull-terminated name string.

◆ set_resource_view_name()

virtual void reshade::api::device::set_resource_view_name ( resource_view  handle,
const char *  name 
)
pure virtual

Associates a name with a resource view, for easier debugging in external tools.

Parameters
handleResource view to associate a name with.
nameNull-terminated name string.

◆ unmap_buffer_region()

virtual void reshade::api::device::unmap_buffer_region ( resource  resource)
pure virtual

Unmaps a previously mapped buffer resource.

Parameters
resourceBuffer resource to unmap from host memory.

◆ unmap_texture_region()

virtual void reshade::api::device::unmap_texture_region ( resource  resource,
uint32_t  subresource 
)
pure virtual

Unmaps a previously mapped texture resource.

Parameters
resourceTexture resource to unmap from host memory.
subresourceIndex of the subresource to unmap (level + (layer * levels)).

◆ update_buffer_region()

virtual void reshade::api::device::update_buffer_region ( const void *  data,
resource  resource,
uint64_t  offset,
uint64_t  size 
)
pure virtual

Uploads data to a buffer resource.

Parameters
dataPointer to the data to upload.
resourceBuffer resource to upload to.
offsetOffset (in bytes) into the buffer resource to start uploading to.
sizeNumber of bytes to upload.

◆ update_descriptor_sets()

virtual void reshade::api::device::update_descriptor_sets ( uint32_t  count,
const descriptor_set_update updates 
)
pure virtual

Updates the contents of multiple descriptor sets with the specified descriptors.

Parameters
countNumber of updates to process.
updatesPointer to an array of descriptor set updates to process.

◆ update_descriptors()

void reshade::api::device::update_descriptors ( const descriptor_set_update update)
inline

Updates the contents of a descriptor set with the specified descriptors.

Parameters
updateDescriptor set update to process.

◆ update_texture_region()

virtual void reshade::api::device::update_texture_region ( const subresource_data data,
resource  resource,
uint32_t  subresource,
const subresource_box box = nullptr 
)
pure virtual

Uploads data to a texture resource.

Parameters
dataPointer to the data to upload.
resourceTexture resource to upload to.
subresourceIndex of the subresource to upload to (level + (layer * levels)).
boxOptional 3D box (or nullptr to reference the entire subresource) that defines the region in the resource to upload to.

The documentation for this struct was generated from the following file: