Skip to content

Commit

Permalink
[hdSt] Add argument to specify buffer usage for standalone buffer res…
Browse files Browse the repository at this point in the history
…ources.

This allows us to correctly specify that the drawIndirectResult should be a
storage buffer when creating it.

(Internal change: 2297310)
  • Loading branch information
clach authored and pixar-oss committed Oct 2, 2023
1 parent 1e488ba commit 7f84c75
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pxr/imaging/hdSt/indirectDrawBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ HdSt_IndirectDrawBatch::_BeginGPUCountVisibleInstances(

_resultBuffer =
resourceRegistry->RegisterBufferResource(
_tokens->drawIndirectResult, tupleType);
_tokens->drawIndirectResult, tupleType, HgiBufferUsageStorage);
}

// Reset visible item count
Expand Down
5 changes: 3 additions & 2 deletions pxr/imaging/hdSt/pipelineDrawBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ _AllocateTessFactorsBuffer(

return resourceRegistry->RegisterBufferResource(
HdTokens->tessFactors,
HdTupleType{HdTypeHalfFloat, numElements*numTessFactorsPerElement});
HdTupleType{HdTypeHalfFloat, numElements*numTessFactorsPerElement},
HgiBufferUsageUniform);
}

} // annonymous namespace
Expand Down Expand Up @@ -1883,7 +1884,7 @@ HdSt_PipelineDrawBatch::_BeginGPUCountVisibleInstances(

_resultBuffer =
resourceRegistry->RegisterBufferResource(
_tokens->drawIndirectResult, tupleType);
_tokens->drawIndirectResult, tupleType, HgiBufferUsageStorage);
}

// Reset visible item count
Expand Down
7 changes: 4 additions & 3 deletions pxr/imaging/hdSt/resourceRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ HdStResourceRegistry::RegisterDispatchBuffer(
HdStBufferResourceSharedPtr
HdStResourceRegistry::RegisterBufferResource(
TfToken const &role,
HdTupleType tupleType)
HdTupleType tupleType,
HgiBufferUsage bufferUsage)
{
HdStBufferResourceSharedPtr const result =
std::make_shared<HdStBufferResource>(
Expand All @@ -544,8 +545,8 @@ HdStResourceRegistry::RegisterBufferResource(
size_t byteSize = HdDataSizeOfTupleType(tupleType);

HgiBufferDesc bufDesc;
bufDesc.usage= HgiBufferUsageUniform;
bufDesc.byteSize= byteSize;
bufDesc.usage = bufferUsage;
bufDesc.byteSize = byteSize;
HgiBufferHandle buffer = _hgi->CreateBuffer(bufDesc);

result->SetAllocation(buffer, byteSize);
Expand Down
3 changes: 2 additions & 1 deletion pxr/imaging/hdSt/resourceRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ class HdStResourceRegistry final : public HdResourceRegistry
HDST_API
HdStBufferResourceSharedPtr RegisterBufferResource(
TfToken const &role,
HdTupleType tupleType);
HdTupleType tupleType,
HgiBufferUsage bufferUsage);

/// Remove any entries associated with expired dispatch buffers.
HDST_API
Expand Down

0 comments on commit 7f84c75

Please sign in to comment.