Program Listing for File binding-info.h
↰ Return to documentation for file (include\playback\resource-info\binding-info.h
)
/******************************************************************************
© Intel Corporation.
This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.
This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.
******************************************************************************/
#pragma once
#include "api-types/api-types.h"
#include "playback/metadata-extraction/metadata-extractor-ex.h"
#include "playback/resource-info/detail/utilities.h"
#include "playback/resource-info/resource-info-types.h"
#include <algorithm>
#include <vector>
namespace gpa {
namespace playback {
using Descriptors = std::vector<InputBindingInfo const*>;
class PipelineStateInfo final
{
public:
PipelineInfo const* pipeline{nullptr};
std::vector<PipelineConstantInfo const*> pipelineConstants;
void Clear()
{
pipeline = nullptr;
pipelineConstants.clear();
}
};
class BindingInfo final
{
public:
inline void Clear()
{
computePipeline.Clear();
graphicsPipeline.Clear();
graphicsDescriptors.clear();
computeDescriptors.clear();
indexBufferInfo = nullptr;
vertexBufferInfos.clear();
inputLayoutInfo = nullptr;
renderTargets.clear();
indirectBuffers.clear();
memoryBarriers.clear();
resourceTransfers.clear();
shadingRateImageInfo = nullptr;
raygenShaderTableInfo = nullptr;
missShaderTableInfo = nullptr;
hitShaderTableInfo = nullptr;
callableShaderTableInfo = nullptr;
}
PipelineStateInfo computePipeline;
PipelineStateInfo graphicsPipeline;
PipelineStateInfo raytracingPipeline;
Descriptors graphicsDescriptors;
Descriptors computeDescriptors;
Descriptors raytracingDescriptors;
IndexBufferInfo const* indexBufferInfo{nullptr};
std::vector<VertexBufferInfo const*> vertexBufferInfos;
InputLayoutInfo const* inputLayoutInfo{nullptr};
std::vector<RenderTargetInfo const*> renderTargets;
std::vector<IndirectBufferInfo const*> indirectBuffers;
std::vector<MemoryBarrierInfo const*> memoryBarriers;
std::vector<ResourceTransferInfo const*> resourceTransfers;
ShadingRateImageInfo const* shadingRateImageInfo{nullptr};
RaygenShaderTableInfo const* raygenShaderTableInfo{nullptr};
MissShaderTableInfo const* missShaderTableInfo{nullptr};
HitShaderTableInfo const* hitShaderTableInfo{nullptr};
CallableShaderTableInfo const* callableShaderTableInfo{nullptr};
};
namespace detail {
inline void PopulatePipelineBindingInfo(
MetadataExtractorEx const& metadataExtractor,
ResourceInfo::Usage usage,
uint64_t callIndex,
PipelineStateInfo& pipelineInfo)
{
pipelineInfo.Clear();
for (auto const& resourceInfo : metadataExtractor.GetResourceInfos(usage, callIndex)) {
pipelineInfo.pipeline = resourceInfo.As<PipelineInfo>();
if (!pipelineInfo.pipeline) {
continue;
}
switch (usage) {
case ResourceInfo::Usage::COMPUTE_PIPELINE:
usage = ResourceInfo::Usage::COMPUTE_DESCRIPTOR;
break;
case ResourceInfo::Usage::GRAPHICS_PIPELINE:
usage = ResourceInfo::Usage::GRAPHICS_DESCRIPTOR;
break;
case ResourceInfo::Usage::RAYTRACING_PIPELINE:
usage = ResourceInfo::Usage::RAYTRACING_DESCRIPTOR;
break;
}
for (auto const& resourceInfoEx : resourceInfo.GetResourceInfoExs(usage, callIndex)) {
auto const pPipelineConstantInfo = resourceInfoEx.As<PipelineConstantInfo>();
if (pPipelineConstantInfo) {
pipelineInfo.pipelineConstants.push_back(pPipelineConstantInfo);
}
}
break;
}
}
inline void PopulateDescriptors(
MetadataExtractorEx const& metadataExtractor,
ResourceInfo::Usage usage,
uint64_t callIndex,
Descriptors& descriptors)
{
for (auto const& resourceInfo : metadataExtractor.GetResourceInfos(usage, callIndex)) {
switch (resourceInfo.GetTypeId()) {
case ResourceInfo::GetTypeId<BufferInfo>():
case ResourceInfo::GetTypeId<SamplerInfo>():
case ResourceInfo::GetTypeId<TextureInfo>():
for (auto const& resourceInfoEx : resourceInfo.GetResourceInfoExs(usage, callIndex)) {
auto pInputBindingInfo = resourceInfoEx.As<InputBindingInfo>();
if (pInputBindingInfo) {
descriptors.push_back(pInputBindingInfo);
}
}
}
}
}
inline void PopulateInputAssemblyBindingInfo(
MetadataExtractorEx const& metadataExtractor,
uint64_t callIndex,
BindingInfo& bindingInfo)
{
auto usage = ResourceInfo::Usage::GRAPHICS_INPUT_ASSEMBLY;
for (auto const& resourceInfo : metadataExtractor.GetResourceInfos(usage, callIndex)) {
for (auto const& resourceInfoEx : resourceInfo.GetResourceInfoExs(usage, callIndex)) {
switch (resourceInfoEx.GetTypeId()) {
case ResourceInfo::Ex::GetTypeId<IndexBufferInfo>():
bindingInfo.indexBufferInfo = resourceInfoEx.As<IndexBufferInfo>();
break;
case ResourceInfo::Ex::GetTypeId<VertexBufferInfo>():
detail::AddInfoPtrToVector(&resourceInfoEx, bindingInfo.vertexBufferInfos);
break;
}
}
InputLayoutInfo const* inputLayout = resourceInfo.As<InputLayoutInfo>();
if (inputLayout) {
bindingInfo.inputLayoutInfo = inputLayout;
}
}
detail::SortVector(
bindingInfo.vertexBufferInfos,
[](VertexBufferInfo const* lhs, VertexBufferInfo const* rhs) {
return lhs->binding < rhs->binding;
});
}
inline void PopulateShadingRateImageBindingInfo(
MetadataExtractorEx const& metadataExtractor,
uint64_t callIndex,
BindingInfo& bindingInfo)
{
using namespace detail;
auto usage = ResourceInfo::Usage::GRAPHICS_RASTERIZATION_STATE;
for (auto const& resourceInfo : metadataExtractor.GetResourceInfos(usage, callIndex)) {
for (auto const& resourceInfoEx : resourceInfo.GetResourceInfoExs(usage, callIndex)) {
switch (resourceInfoEx.GetTypeId()) {
case ResourceInfo::Ex::GetTypeId<ShadingRateImageInfo>():
bindingInfo.shadingRateImageInfo = resourceInfoEx.As<ShadingRateImageInfo>();
break;
}
}
}
}
inline void PopulateRenderTargetBindingInfos(
MetadataExtractorEx const& metadataExtractor,
uint64_t callIndex,
BindingInfo& bindingInfo)
{
bindingInfo.renderTargets.clear();
auto usage = ResourceInfo::Usage::GRAPHICS_OUTPUT;
for (auto const& resourceInfo : metadataExtractor.GetResourceInfos(usage, callIndex)) {
for (auto const& resourceInfoEx : resourceInfo.GetResourceInfoExs(usage, callIndex)) {
detail::AddInfoPtrToVector(&resourceInfoEx, bindingInfo.renderTargets);
}
}
}
inline void PopulateArgumentBindingInfos(
MetadataExtractorEx const& metadataExtractor,
uint64_t callIndex,
BindingInfo& bindingInfo)
{
using namespace detail;
auto usage = ResourceInfo::Usage::ARGUMENT;
for (auto const& resourceInfo : metadataExtractor.GetResourceInfos(usage, callIndex)) {
for (auto const& resourceInfoEx : resourceInfo.GetResourceInfoExs(usage, callIndex)) {
switch (resourceInfoEx.GetTypeId()) {
case ResourceInfo::Ex::GetTypeId<IndirectBufferInfo>(): {
detail::AddInfoPtrToVector(&resourceInfoEx, bindingInfo.indirectBuffers);
} break;
case ResourceInfo::Ex::GetTypeId<MemoryBarrierInfo>(): {
detail::AddInfoPtrToVector(&resourceInfoEx, bindingInfo.memoryBarriers);
} break;
case ResourceInfo::Ex::GetTypeId<ResourceTransferInfo>(): {
detail::AddInfoPtrToVector(&resourceInfoEx, bindingInfo.resourceTransfers);
} break;
case ResourceInfo::Ex::GetTypeId<RaygenShaderTableInfo>(): {
bindingInfo.raygenShaderTableInfo = resourceInfoEx.As<RaygenShaderTableInfo>();
} break;
case ResourceInfo::Ex::GetTypeId<MissShaderTableInfo>(): {
bindingInfo.missShaderTableInfo = resourceInfoEx.As<MissShaderTableInfo>();
} break;
case ResourceInfo::Ex::GetTypeId<HitShaderTableInfo>(): {
bindingInfo.hitShaderTableInfo = resourceInfoEx.As<HitShaderTableInfo>();
} break;
case ResourceInfo::Ex::GetTypeId<CallableShaderTableInfo>(): {
bindingInfo.callableShaderTableInfo = resourceInfoEx.As<CallableShaderTableInfo>();
} break;
default:
break;
}
}
}
SortVectorAndRemoveDuplicates(bindingInfo.indirectBuffers);
SortVectorAndRemoveDuplicates(bindingInfo.resourceTransfers);
}
} // namespace detail
inline void PopulateBindingInfo(
MetadataExtractorEx const& metadataExtractor,
uint64_t callIndex,
BindingInfo& bindingInfo)
{
#if ENABLE_METADATA_DEBUGGING
if (callIndex == BREAK_AT_CALL_INDEX) {
int breaker = 0;
(void)breaker;
}
#endif
bindingInfo.Clear();
detail::PopulatePipelineBindingInfo(metadataExtractor, ResourceInfo::Usage::COMPUTE_PIPELINE, callIndex, bindingInfo.computePipeline);
detail::PopulatePipelineBindingInfo(metadataExtractor, ResourceInfo::Usage::RAYTRACING_PIPELINE, callIndex, bindingInfo.raytracingPipeline);
detail::PopulatePipelineBindingInfo(metadataExtractor, ResourceInfo::Usage::GRAPHICS_PIPELINE, callIndex, bindingInfo.graphicsPipeline);
detail::PopulateDescriptors(metadataExtractor, ResourceInfo::Usage::COMPUTE_DESCRIPTOR, callIndex, bindingInfo.computeDescriptors);
detail::PopulateDescriptors(metadataExtractor, ResourceInfo::Usage::RAYTRACING_DESCRIPTOR, callIndex, bindingInfo.raytracingDescriptors);
detail::PopulateDescriptors(metadataExtractor, ResourceInfo::Usage::GRAPHICS_DESCRIPTOR, callIndex, bindingInfo.graphicsDescriptors);
detail::PopulateInputAssemblyBindingInfo(metadataExtractor, callIndex, bindingInfo);
detail::PopulateShadingRateImageBindingInfo(metadataExtractor, callIndex, bindingInfo);
detail::PopulateRenderTargetBindingInfos(metadataExtractor, callIndex, bindingInfo);
detail::PopulateArgumentBindingInfos(metadataExtractor, callIndex, bindingInfo);
}
} // namespace playback
} // namespace gpa