Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
blowbox::GpuResource Class Reference

#include <gpu_resource.h>

Public Member Functions

 GpuResource ()
 
 GpuResource (ID3D12Resource *resource, D3D12_RESOURCE_STATES current_state)
 
virtual ~GpuResource ()
 
void Associate (ID3D12Resource *resource, D3D12_RESOURCE_STATES current_state)
 
void Destroy ()
 
ID3D12Resource * operator-> ()
 
const ID3D12Resource * operator-> () const
 
 operator ID3D12Resource * ()
 
ID3D12Resource * Get ()
 
const D3D12_RESOURCE_STATES & GetState () const
 
const D3D12_RESOURCE_STATES & GetTransitionState () const
 

Protected Member Functions

void AddToMemoryProfiler ()
 
void RemoveFromMemoryProfiler ()
 

Protected Attributes

WString name_
 
ID3D12Resource * resource_
 
D3D12_RESOURCE_STATES usage_state_
 
D3D12_RESOURCE_STATES transition_state_
 
D3D12_GPU_VIRTUAL_ADDRESS gpu_virtual_address_
 

Friends

class CommandContext
 
class MemoryProfiler
 
class CompareGpuResourceByName
 
class CompareGpuResourceBySize
 
class CompareGpuResourceByFormat
 
class CompareGpuResourceByNameReverted
 
class CompareGpuResourceBySizeReverted
 
class CompareGpuResourceByFormatReverted
 

Detailed Description

Wraps ID3D12Resource objects.

This GpuResource class wraps the entire ID3D12Resource object. It is useful because it keeps track of the current resource state it currently is in and allows for efficient state switching by CommandContexts. Every resource in Blowbox should be wrapped by this class. If you want access to the underlying ID3D12Resource, you can use GpuResource::Get().

Inheritance diagram for blowbox::GpuResource:
blowbox::GpuBuffer blowbox::PixelBuffer blowbox::ByteAddressBuffer blowbox::StructuredBuffer blowbox::TypedBuffer blowbox::UploadBuffer blowbox::ColorBuffer blowbox::DepthBuffer

Constructor & Destructor Documentation

blowbox::GpuResource::GpuResource ( )

Constructs an empty GpuResource.

blowbox::GpuResource::GpuResource ( ID3D12Resource *  resource,
D3D12_RESOURCE_STATES  current_state 
)

Constructs a GpuResource that wraps a certain ID3D12Resource object.

Parameters
[in]resourceThe resource that needs to be wrapped.
[in]current_stateThe state of the resource that needs to be wrapped.
blowbox::GpuResource::~GpuResource ( )
virtual

Destructs a GpuResource.

Member Function Documentation

void blowbox::GpuResource::AddToMemoryProfiler ( )
protected

Adds this GpuResource to the MemoryProfiler.

void blowbox::GpuResource::Associate ( ID3D12Resource *  resource,
D3D12_RESOURCE_STATES  current_state 
)

Associate this GpuResource with another ID3D12Resource.

Parameters
[in]resourceThe resource that this GpuResource should associate itself with.
[in]current_stateThe state of the resource that this GpuResource should associate itself with.
void blowbox::GpuResource::Destroy ( )

Destroys the underlying GpuResource.

ID3D12Resource* blowbox::GpuResource::Get ( )
inline

Returns the underlying ID3D12Resource.

const D3D12_RESOURCE_STATES& blowbox::GpuResource::GetState ( ) const
inline

Returns the current resource state of the resource.

Returns
The current resource state of the resource.
const D3D12_RESOURCE_STATES& blowbox::GpuResource::GetTransitionState ( ) const
inline

Returns the current transition state of the resource.

Returns
The current transition state of the resource.
Remarks
The transition state is used by the CommandContext in order to queue up resource transitions. A resource transition can be triggered on a GpuResource, but it doesn't need to be immediately transitioned to the new resource state. While it is in that limbo-state, this is will return the state that is going to transition towards.
blowbox::GpuResource::operator ID3D12Resource * ( )
inline

Implicitly convert this GpuResource to a ID3D12Resource.

ID3D12Resource* blowbox::GpuResource::operator-> ( )
inline

Pointer operator that returns the underlying resource.

const ID3D12Resource* blowbox::GpuResource::operator-> ( ) const
inline

Pointer operator that returns the underlying resource.

void blowbox::GpuResource::RemoveFromMemoryProfiler ( )
protected

Removes this GpuResource from the MemoryProfiler.

Member Data Documentation

D3D12_GPU_VIRTUAL_ADDRESS blowbox::GpuResource::gpu_virtual_address_
protected

The virtual address of the ID3D12Resource in VRAM.

WString blowbox::GpuResource::name_
protected

The name of this resource.

ID3D12Resource* blowbox::GpuResource::resource_
protected

The ID3D12Resource that is being wrapped by the GpuResource.

D3D12_RESOURCE_STATES blowbox::GpuResource::transition_state_
protected

The current transition state of the GpuResource.

D3D12_RESOURCE_STATES blowbox::GpuResource::usage_state_
protected

The current resource state of the ID3D12Resource.


The documentation for this class was generated from the following files: