Program Listing for File geometry-extractor.h

Return to documentation for file (include\playback\geometry-extraction\geometry-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-broadcaster.h"
#include "playback/callable-receiver.h"
#include "playback/metadata-extraction/metadata-types.h"
#include "playback/resource-info/detail/span.h"

#include <map>
#include <vector>

namespace gpa {
namespace api_types {

struct VertexInputElementExtended;

}  // namespace api_types

namespace playback {

class MetadataExtractorEx;

class GeometryExtractor
    : public CallableReceiver,
      public CallableBroadcaster,
      public CallableCallbacks
{
public:
    struct Result final
    {
        enum class State {
            // clang-format off
            PENDING                            =  0,
            SUCCESS                            =  1,
            FAILURE_UNKNOWN                    = -1,
            FAILURE_INVALID_REQUEST            = -2,
            FAILURE_UNSUPPORTED                = -3,
            FAILURE_NO_SHADER                  = -4,
            FAILURE_NO_GEOMETRY                = -5,
            FAILURE_POSITION_PARAM_NOT_FOUND   = -6,
            FAILURE_INTERNAL                   = -7,
            INSUFFICIENT_BUFFER_SIZE           = -8,
            // clang-format on
        };

        operator bool() const;

        State state{State::PENDING};
        std::vector<uint8_t> data;
        uint32_t dataStride = 0;
        std::vector<api_types::VertexInputElementExtended> layout;
        api_types::PrimitiveTopology topology = api_types::GPA_PRIMITIVE_TOPOLOGY_UNKNOWN;
        uint64_t primitiveCount = 0;
        uint32_t controlPointCount = 0;
        float viewportAspect = 1.0f;
    };

    struct Request final
    {
        enum class Stage {
            Unspecified = 0,
            DrawInput,
            DrawPostVertexStage,
            DrawPostDomainStage,
            DrawPostGeometryStage,
        };

        enum class Type {
            Unspecified = 0,
            PositionOnly = 1,
            Full = 2
        };

        struct Info final
        {
            uint64_t callIndex{0};
            Stage stage{Stage::Unspecified};
            Type type{Type::Unspecified};

            Result result{};
        };

        operator bool() const;

        size_t infoCount{0};
        Info* pInfos{nullptr};
    };

    GeometryExtractor() = default;

    virtual ~GeometryExtractor();

    virtual void SetRequest(Request& request);

    void ReprocessRequest();

    virtual void SetSOBufferSize(size_t size);

    virtual size_t GetSOBufferSizeHint();

    virtual void Clear();

    virtual void PostSetupRange(CallableCache* pCallableCache) override;
    virtual void PreExecuteRange(CallableCache* pCallableCache) override;
    virtual void PreExecuteCall(Callable* pCallable, uint64_t callIndex) override;
    virtual void PostExecuteCall(Callable* pCallable, uint64_t callIndex) override;
    virtual void PostExecuteRange(CallableCache* pCallableCache) override;
    void ConnectExecutionCallbacks(ExecutionCallbacks const& executionCallbacks) override final;
    void DisconnectExecutionCallbacks() override final;
    ExecutionCallbacks mExecutionCallbacks{};

protected:
    detail::Span<Request::Info> GetRequestInfos();

    detail::Span<Request::Info> GetRequestInfos(uint64_t callIndex);

    MetadataExtractorEx const* mMetadataExtractor{nullptr};

private:
    Request* mRequest{nullptr};
    uint8_t* mRequestResultData{nullptr};
    GeometryExtractor(GeometryExtractor const&) = delete;
    GeometryExtractor& operator=(GeometryExtractor const&) = delete;
};

bool operator==(GeometryExtractor::Request::Info const& lhs, GeometryExtractor::Request::Info const& rhs);

bool operator!=(GeometryExtractor::Request::Info const& lhs, GeometryExtractor::Request::Info const& rhs);

bool operator<(GeometryExtractor::Request::Info const& lhs, GeometryExtractor::Request::Info const& rhs);

bool operator==(GeometryExtractor::Result const& lhs, GeometryExtractor::Result const& rhs);

bool operator!=(GeometryExtractor::Result const& lhs, GeometryExtractor::Result const& rhs);

bool operator<(GeometryExtractor::Result const& lhs, GeometryExtractor::Result const& rhs);

bool operator==(GeometryExtractor::Request const& lhs, GeometryExtractor::Request const& rhs);

bool operator!=(GeometryExtractor::Request const& lhs, GeometryExtractor::Request const& rhs);

bool operator<(GeometryExtractor::Request const& lhs, GeometryExtractor::Request const& rhs);

}  // namespace playback
}  // namespace gpa