#include "xgpuvertexrawrequest.h"

XGpuVertexRawRequest::XGpuVertexRawRequest()
    : XAsset()
    , mType(0)
    , mBaseAddress(0)
    , mEndian(0)
    , mSize(0)
    , mAddressClamp(0)
    , mRequestSize(0)
    , mClampDisable(0)
{
    SetName("GPU Vertex Raw Request");
}

void XGpuVertexRawRequest::ParseData(XDataStream *aStream)
{
    quint32 w0;
    *aStream >> w0;
    if (IsDebug())
    {
        qDebug() << QString("[%1] w0 = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(w0);
    }

    quint32 w1;
    *aStream >> w1;
    if (IsDebug())
    {
        qDebug() << QString("[%1] w1 = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(w1);
    }

    mType = (w0      ) & 0x3u;
    mBaseAddress = (w0 >> 2 ) & 0x3FFFFFFFu;
    mEndian = (w1      ) & 0x3u;
    mSize = (w1 >> 2 ) & 0xFFFFFFu;
    mAddressClamp = (w1 >> 26) & 0x1u;
    mRequestSize = (w1 >> 28) & 0x3u;
    mClampDisable = (w1 >> 30) & 0x3u;

    if (IsDebug())
    {
        qDebug() << QString("[%1] mType = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mType);
        qDebug() << QString("[%1] mBaseAddress = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mBaseAddress);
        qDebug() << QString("[%1] mEndian = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(w1);
        qDebug() << QString("[%1] mSize = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mSize);
        qDebug() << QString("[%1] mAddressClamp = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mAddressClamp);
        qDebug() << QString("[%1] mRequestSize = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mRequestSize);
        qDebug() << QString("[%1] mClampDisable = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mClampDisable);
    }
}

void XGpuVertexRawRequest::Clear()
{
    
}
