Skip to content

Commit

Permalink
Ensure that SimpleShaderObjectData returns nullptr for empty buffer
Browse files Browse the repository at this point in the history
This is a C++ technicality, and is not known to have caused any issue.

https://en.cppreference.com/w/cpp/container/vector/data says:
"If size() is ​0​, data() may or may not return a null pointer."

Thus, we check if the underlying std::vector is empty and then explicitly return nullptr
in this case.
  • Loading branch information
aleino-nv committed Nov 1, 2024
1 parent ad8092e commit 9d292cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/rhi-shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class SimpleShaderObjectData

Index getCount() { return m_ordinaryData.size(); }
void setCount(Index count) { m_ordinaryData.resize(count); }
uint8_t* getBuffer() { return m_ordinaryData.data(); }
uint8_t* getBuffer() { return m_ordinaryData.empty() ? nullptr : m_ordinaryData.data(); }

/// Returns a StructuredBuffer resource view for GPU access into the buffer content.
/// Creates a StructuredBuffer resource if it has not been created.
Expand Down

0 comments on commit 9d292cb

Please sign in to comment.