HoudiniEngineForUnreal icon indicating copy to clipboard operation
HoudiniEngineForUnreal copied to clipboard

Error when calling Asynchronous Attribute API in Houdini Engine 7.0

Open dashuai009 opened this issue 1 year ago • 0 comments

I am trying to test the Asynchronous Attribute API in Houdini Engine 7.0, but I encounter an error immediately upon calling these asynchronous APIs.

Here is a sample of my test code:

all test_code.zip


bool SetHEAttrByAsyncApi(const HAPI_Session* Session, int PointCount, HAPI_NodeId NodeId2,
                        TArray<float> StaticMeshVertices)
{
    TRACE_CPUPROFILER_EVENT_SCOPE(SetHEAttr)
    // Create point attribute info.
    HAPI_AttributeInfo AttributeInfoPoint;
    FHoudiniApi::AttributeInfo_Init(&AttributeInfoPoint);
    //FMemory::Memzero< HAPI_AttributeInfo >( AttributeInfoPoint );
    AttributeInfoPoint.count = PointCount;
    AttributeInfoPoint.tupleSize = 3;
    AttributeInfoPoint.exists = true;
    AttributeInfoPoint.owner = HAPI_ATTROWNER_POINT;
    AttributeInfoPoint.storage = HAPI_STORAGETYPE_FLOAT;
    AttributeInfoPoint.originalOwner = HAPI_ATTROWNER_INVALID;
    HOUDINI_CHECK_ERROR_RETURN(FHoudiniApi::AddAttribute( Session, NodeId2, 0,
                                    HAPI_UNREAL_ATTRIB_POSITION, &AttributeInfoPoint), false);

    int cnt = StaticMeshVertices.Num() / 3;
    int job1 = 0;
    int job2 = 0;
    HOUDINI_CHECK_ERROR_RETURN(FHoudiniApi::SetAttributeFloatDataAsync(
                                    FHoudiniEngine::Get().GetSession(), NodeId2, 0,
                                    HAPI_UNREAL_ATTRIB_POSITION, &AttributeInfoPoint, StaticMeshVertices.GetData(),
                                    0 , cnt / 2, &job1), false);
    HOUDINI_CHECK_ERROR_RETURN(FHoudiniApi::SetAttributeFloatDataAsync(
                                    FHoudiniEngine::Get().GetSession(), NodeId2, 0,
                                    HAPI_UNREAL_ATTRIB_POSITION, &AttributeInfoPoint,
                                    StaticMeshVertices.GetData() + (cnt /2) * 3, cnt / 2,
                                    cnt - cnt / 2, &job2), false);
    int ready_cnt = 0;
    TRACE_CPUPROFILER_EVENT_SCOPE(SetHEAttr_sleep)
    while (true)
    {
        if (ready_cnt == 2)
        {
            break;
        }
        HAPI_JobStatus JobStatus;
        FHoudiniApi::GetJobStatus(Session, job1, &JobStatus);
        if (JobStatus == HAPI_JobStatus::HAPI_JOB_STATUS_IDLE)
        {
            ready_cnt++;
        }
        FHoudiniApi::GetJobStatus(Session, job2, &JobStatus);
        if (JobStatus == HAPI_JobStatus::HAPI_JOB_STATUS_IDLE)
        {
            ready_cnt++;
        }
        FPlatformProcess::Sleep(0.005f);
    }
    return true;
}

SetAttributeFloatDataAsync returns HAPI_RESULT_FAILURE without any error message or indication.

Env:

  • OS: Windows 11
  • Houdini: 20.5.370
  • Houdini Engine for Unreal: git checkout v2.2.2
  • Unreal Engine: 5.3

Could you please help me investigate this issue?

I have raised another related issue in the Houdini forum: How to use async api in HAPI 7.0 ?

dashuai009 avatar Oct 18 '24 04:10 dashuai009