Program Listing for File shader-profile-extractor.h

Return to documentation for file (include\playback\shader-profile-extraction\shader-profile-extractor.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 "playback/callable-receiver.h"
#include "playback/metadata-extraction/metadata-types.h"
#include "shader-profiler/types.h"

namespace gpa {
namespace playback {

struct ProfileShaderRequestWithType : ProfileShaderRequest
{
    gpa::shader_profiler::ProfilingMode profilingType{gpa::shader_profiler::ProfilingMode::kOverview};
    std::vector<gpa::shader_profiler::ShaderStage> stagesForProfiling{
        gpa::shader_profiler::ShaderStage::kVertex,
        gpa::shader_profiler::ShaderStage::kHull,
        gpa::shader_profiler::ShaderStage::kDomain,
        gpa::shader_profiler::ShaderStage::kGeometry,
        gpa::shader_profiler::ShaderStage::kAmplification,
        gpa::shader_profiler::ShaderStage::kMesh,
        gpa::shader_profiler::ShaderStage::kFragment,
        gpa::shader_profiler::ShaderStage::kCompute,
        gpa::shader_profiler::ShaderStage::kLibrary};
};

class ShaderProfileExtractor
    : public CallableReceiver
{
public:
    virtual ~ShaderProfileExtractor() = 0;

    virtual bool IsAvailable() const = 0;

    inline virtual void SetRequest(ProfileShaderRequestWithType const& request) = 0;

    virtual gpa::shader_profiler::ProfiledShaders GetResult() const = 0;
};

inline ShaderProfileExtractor::~ShaderProfileExtractor()
{
}

inline ShaderStage ConvertShaderStageSPToRainier(gpa::shader_profiler::ShaderStage type)
{
    switch (type) {
    case gpa::shader_profiler::ShaderStage::kVertex:
        return ShaderStage::kVertex;
    case gpa::shader_profiler::ShaderStage::kHull:
        return ShaderStage::kHull;
    case gpa::shader_profiler::ShaderStage::kDomain:
        return ShaderStage::kDomain;
    case gpa::shader_profiler::ShaderStage::kGeometry:
        return ShaderStage::kGeometry;
    case gpa::shader_profiler::ShaderStage::kMesh:
        return ShaderStage::kMesh;
    case gpa::shader_profiler::ShaderStage::kFragment:
        return ShaderStage::kFragment;
    case gpa::shader_profiler::ShaderStage::kCompute:
        return ShaderStage::kCompute;
    case gpa::shader_profiler::ShaderStage::kLibrary:
        return ShaderStage::kLibrary;
    case gpa::shader_profiler::ShaderStage::kAmplification:
        return ShaderStage::kAmplification;
    default:
        return ShaderStage::kShaderStageInvalid;
    }
}

inline gpa::shader_profiler::ShaderStage ConvertShaderStageFlagBitsRainierToSP(gpa::api_types::ShaderStageFlagBits type)
{
    switch (type) {
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_VERTEX:
        return gpa::shader_profiler::ShaderStage::kVertex;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_HULL:
        return gpa::shader_profiler::ShaderStage::kHull;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_DOMAIN:
        return gpa::shader_profiler::ShaderStage::kDomain;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_GEOMETRY:
        return gpa::shader_profiler::ShaderStage::kGeometry;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_MESH:
        return gpa::shader_profiler::ShaderStage::kMesh;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_FRAGMENT:
        return gpa::shader_profiler::ShaderStage::kFragment;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_COMPUTE:
        return gpa::shader_profiler::ShaderStage::kCompute;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_DXIL_LIBRARY:
        return gpa::shader_profiler::ShaderStage::kLibrary;
    case gpa::api_types::ShaderStageFlagBits::GPA_SHADER_STAGE_AMPLIFICATION:
        return gpa::shader_profiler::ShaderStage::kAmplification;
    default:
        return gpa::shader_profiler::ShaderStage::kShaderStageInvalid;
    }
}

inline api_types::ShaderLanguage ConvertShaderLanguageSPToRainier(gpa::shader_profiler::ShaderLanguage type)
{
    switch (type) {
    case gpa::shader_profiler::ShaderLanguage::kDXBC:
        return api_types::ShaderLanguage::GPA_SHADER_LANGUAGE_DXBC;
    case gpa::shader_profiler::ShaderLanguage::kDXIL:
        return api_types::ShaderLanguage::GPA_SHADER_LANGUAGE_DXIL;
    case gpa::shader_profiler::ShaderLanguage::kGLSL:
        return api_types::ShaderLanguage::GPA_SHADER_LANGUAGE_GLSL;
    case gpa::shader_profiler::ShaderLanguage::kHLSL:
        return api_types::ShaderLanguage::GPA_SHADER_LANGUAGE_HLSL;
    case gpa::shader_profiler::ShaderLanguage::kISA:
        return api_types::ShaderLanguage::GPA_SHADER_LANGUAGE_ISA;
    case gpa::shader_profiler::ShaderLanguage::kSPIRV:
        return api_types::ShaderLanguage::GPA_SHADER_LANGUAGE_SPIRV;
    default:
        return api_types::ShaderLanguage::GPA_SHADER_LANGUAGE_UNKNOWN;
    }
}

}  // namespace playback
}  // namespace gpa