Class ResourceExtractor
Defined in File resource-extractor.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Types
public gpa::playback::CallableReceiver
(Class CallableReceiver)public gpa::playback::CallableBroadcaster
(Class CallableBroadcaster)public gpa::playback::CallableCallbacks
(Class CallableCallbacks)
Class Documentation
-
class ResourceExtractor : public gpa::playback::CallableReceiver, public gpa::playback::CallableBroadcaster, public gpa::playback::CallableCallbacks
Provides access to resource data for a captured range
To extract raw binary resource data for a given
ResourceInfo, determine
which ResourceInfo(s) to extract using the
MetadataExtractor. In this
example we're looking for
RenderTargetInfoobjects bound at call index
128. To find
RenderTargetInfo objects we'll use GRAPHICS_OUTPUT for our ResourceInfo::Usage. As we encounter RenderTargetInfoobjects we'll fill
out the necessary fields in a std::vector<> of
ResourceExtractor::Request::Infoobjects.
Note that a single
ResourceExtractor::Requestmay have any number of ResourceExtractor::Request::Infos with
different ResourceInfos, call indices, and
ResourceInfo::Ex objects.Once we have all of the Request::Infostd::vector<ResourceExtractor::Request::Info> requestInfos; auto usage = ResourceInfo::Usage::GRAPHICS_OUTPUT; uint64_t callIndex = 128; for (auto const& resourceInfo : playbackEngine.GetMetadataExtractor().GetResourceInfos(usage, callIndex)) { resourceInfo.ProcessAs<TextureInfo>( [&](TextureInfo const& textureInfo) { ResourceExtractor::Request::Info request{}; request.callIndex = callIndex; request.pResourceInfo = &textureInfo; requestInfos.push_back(request); } ); }
objects that we're interested in we
need to fill out the necessary fields in
ResourceExtractor::Request. We
start by filling out the number of
ResourceExtractor::Request::Info objects and a pointer to our ResourceExtractor::Request::Infoobjects.
Next we get the storage requirements for our
ResourceExtractor::Request using GetRequestStorageSize()and allocate a buffer to hold our data.
We fill out the
ResourceExtractor::Requestobject's pData field with that
buffer and call Execute() on our
PlaybackEngine.
Note that the call to playbackEngine.Execute() will cause the passed in
ResourceExtractor::Request::Info objects to be sorted.Finally we loop over our ResourceExtractor::Requests and process each ResourceExtractor::Result. Note that ResourceExtractor::ResultResourceExtractor::Request request{}; request.infoCount = requestInfos.size(); request.pInfos = requestInfos.data(); auto storageSize = playbackEngine.GetResourceExtractor().GetRequestStorageSize(request); std::vector<uint8_t> resultStorage(storageSize); request.pData = resultStorage.data(); playbackEngine.Execute(request);
will
evaluate to
true
when converted to abool
if it was successfully
extracted.
for (size_t i = 0; i < request.infoCount; ++i) { auto const& requestInfo = request.pInfos[i]; auto const& result = requestInfo.result; if (requestInfo.pResourceInfo && result) { requestInfo.pResourceInfo->ProcessAs<TextureInfo>( [&](TextureInfo const& textureInfo) { ProcessExtractedTexture(textureInfo, result.dataSize, result.pData); } ); } }
Public Functions
-
ResourceExtractor() = default
Constructs an instance of ResourceExtractor.
-
virtual ~ResourceExtractor()
Destroys this instance of ResourceExtractor.
-
size_t GetRequestStorageSize(Request const &request) const
Gets the size in bytes required to store the ResourceExtractor::Result for a given Request.
Note
Use this method to fill in the pData member of the given Request
Note
If this method is overriden the base implementation must be called
- Parameters
request -- [in] The Request to get the ResourceExtractor::Result storage requirments for
- Returns
The size in bytes required to store the ResourceExtractor::Result for the given Request
-
virtual void SetRequest(Request &request)
Sets a Request on this ResourceExtractor that will be processed during its next execution.
Note
This method will cause the given ResourceExtractor::Result object's ResourceExtractor::Result::Info objects to be sorted
Note
If this method is overriden the base implementation must be called
- Parameters
request -- [in] The Request to set for this ResourceExtractor object's next execution
-
virtual void Clear()
Clears this ResourceExtractor object's Request and ResourceExtractor::Result objects.
Note
If this method is overriden the base implementation must be called
-
ResourceExtractor(MetadataExtractor const &metadataExtractor)
-
virtual void SetRequest(ResourceDataRequest const &request)
-
virtual ResourceDataResult GetResult()
-
virtual void PostSetupRange(CallableCache *pCallableCache) override
-
virtual void PreExecuteRange(CallableCache *pCallableCache) override
-
virtual void PostExecuteRange(CallableCache *pCallableCache) override
-
virtual void ConnectExecutionCallbacks(ExecutionCallbacks const &executionCallbacks) final override
-
virtual void DisconnectExecutionCallbacks() final override
Public Members
-
ExecutionCallbacks mExecutionCallbacks = {}
Protected Functions
-
virtual size_t GetRequestStorageSize(Request::Info const &requestInfo) const
Gets the size in bytes required to store the ResourceExtractor::Result::Info(s) for a given Request::Info @pram [in] requestInfo The Request::Info to get the ResourceExtractor::Result::Info storage requirements for.
Note
If this method is overriden the base implementation must be called
- Returns
The size in bytes required to store the ResourceExtractor::Result::Info(s) for the given Request::Info
-
detail::Span<Request::Info> GetRequestInfos()
Gets all of the Request::Info objects currently set on this ResourceExtractor.
- Returns
All of the Request::Info objects currently set on this ResourceExtractor
-
detail::Span<Request::Info> GetRequestInfos(uint64_t callIndex, Request::Execution stage)
Gets all of the Request::Info objects currently set on this ResourceExtractor for a given call index.
- Parameters
callIndex -- [in] The call index to get the Request::Info objects for
stage -- [in] The stage to get the Request::Info objects for
- Returns
All of the Request::Info objects currently set on this ResourceExtractor for the given call index
Protected Attributes
-
MetadataExtractor const *mMetadataExtractor = {nullptr}
A pointer to the MetadataExtractor associated with this ResourceExtractor.
-
std::vector<uint8_t> mCompatibiltyRequestStorage
-
struct Request
Parameters for obtaining resource data from a ResourceExtractor.
Public Types
Public Functions
-
operator bool() const
Converts this ResourceExtractor::Request to a value indicating whether or not it's valid.
Note
A valid ResourceExtractor::Request has a non zero value for infoCount, a non null pointer for pInfos, and a non null pointer for pData
Public Members
-
size_t infoCount = {0}
This ResourceExtractor::Request object's ResourceExtractor::Request::Info count.
-
Info *pInfos = {nullptr}
This ResourceExtractor::Request object's ResourceExtractor::Request::Info objects.
-
uint8_t *pData = {nullptr}
A pointer to this ResourceExtractor::Request object's result storage.
Note
pData must point to a buffer at least as large as the value obtained from ResourceExtractor::GetRequestStorageSizeInBytes(request)
-
struct Info
Parameters for a single entry in a ResourceExtractor::Request.
Public Members
-
uint64_t callIndex = {0}
The call index to obtain resource data for.
-
ResourceInfo const *pResourceInfo = {nullptr}
A pointer to the ResourceInfo to obtain resource data for.
-
ResourceInfo::Ex const *pResourceInfoEx = {nullptr}
A pointer to the ResourceInfo::Ex to obtain resource data for.
-
api_types::BufferRegion bufferRegion = {api_types::BufferRegion::WholeRegion}
The region of the buffer to objtain resource data for.
Note
This field is only used if pResourceInfo points to a BufferInfo object
Note
This field is only used if pResourceInfoEx is null
-
api_types::TextureRegion textureRegion = {api_types::TextureRegion::WholeRegion}
The region of the texture to objtain resource data for.
Note
This field is only used if pResourceInfo points to a TextureInfo object
Note
This field is only used if pResourceInfoEx is null
-
Result result = {}
The ResourceExtractor::Result populated when this ResourceExtractor::Request is submitted.
-
uint64_t callIndex = {0}
-
operator bool() const
-
struct Result
Parameters for interpreting data obtained from a ResourceExtractor::Request.
Public Types
-
enum class State
Enumeration of possible states of ResourceExtractor::Result.
Values:
-
enumerator PENDING
Indicates that a ResourceExtractor::Request::Info has been created but not yet submitted.
-
enumerator SUCCESS
Indicates that a ResourceExtractor::Request::Info has been submitted and the resource was successfully extracted.
-
enumerator FAILURE_UNKNOWN
Indicates that a ResourceExtractor::Request::Info has been submitted and failed for an unknown reason.
-
enumerator FAILURE_UNSUPPORTED
Indicates that a ResourceExtractor::Request::Info was submitted for a pResourceInfo which does not support extraction.
-
enumerator FAILURE_NO_RESOURCE_INFO_SPECIFIED
Indicates that a ResourceExtractor::Request::Info was submitted wihout a pResourceInfo.
-
enumerator FAILURE_RESOURCE_INFO_MISMATCH
Indicates that a ResourceExtractor::Request::Info was submitted with a pResourceInfoEx that does not reference the given pResourceInfo.
-
enumerator FAILURE_REGION_OUT_OF_BOUNDS
Indicates that a ResourceExtractor::Request::Info was submitted with a BufferRegion or TextureRegion outside of the bounds of the given pResourceInfo.
-
enumerator FAILURE_INTERNAL
Indicates that an internal error occured, indicates that GPA Framework maintenance is required.
-
enumerator PENDING
Public Functions
-
operator bool() const
Converts this ResourceExtractor::Result to a value indicating whether or not it's valid.
Note
A valid ResourceExtractor::Result has a state of State::SUCCESS, a non zero value for dataSize, and a non null pointer for pData
Public Members
-
State state = {State::PENDING}
This ResourceExtractor::Result object's state.
-
size_t dataSize = {0}
The size in bytes of the resource data referenced by this ResourceExtractor::Result.
-
uint8_t *pData = {nullptr}
A pointer to the resource data referenced by this ResourceExtractor::Result.
-
api_types::Format format = {api_types::GPA_FORMAT_UNKNOWN}
Pixel format of the result data. May be different to original texture format (planes)
-
size_t rowPitch = {0}
The size in bytes of a single row of data.
-
size_t slicePitch = {0}
The size in bytes of a single slice of data.
-
enum class State
-
ResourceExtractor() = default