Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when calling Asynchronous Attribute API in Houdini Engine 7.0 #326

Open
dashuai009 opened this issue Oct 18, 2024 · 0 comments
Open

Comments

@dashuai009
Copy link

dashuai009 commented Oct 18, 2024

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant