-
Notifications
You must be signed in to change notification settings - Fork 65
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
[Dawn] Implement DoCompute support in dawn backend and fix sparse descriptor set support #585
Changes from 1 commit
765854d
0d249e9
ca8f887
4044fbb
974630c
8285ec5
ab7f0f7
f1ff19d
68eee4e
54ebfce
5abf09e
7c8448d
94e9bc6
9390fd2
d5e44d6
5ac5121
9f05251
ad578e6
fcb005f
bcbccae
2a38abe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,15 @@ class Buffer { | |
/// |element_count| elements | ||
void SetSizeInBytes(uint32_t size_in_bytes); | ||
|
||
/// max_size_in_bytes_ is the total size in bytes needed to hold the buffer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a definition of the max_size_in_bytes_ field, which should go just before the member declaration at line 200. Separately, there's a fragile disconnect between setting max_size_in_bytes_, element_count_ and resizing the bytes_ vector. No single one of them is the source of truth. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can predict this can get complicated so I filed issue #599 |
||
/// over all ssbo size and ssbo subdata size calls. | ||
/// Sets the max_size_in_bytes_ to |max_size_in_bytes| bytes | ||
void SetMaxSizeInBytes(uint32_t max_size_in_bytes); | ||
/// Returns max_size_in_bytes_ if it is not zero. Otherwise it means this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good comment. |
||
/// buffer is an amber buffer which has a fix size and returns | ||
/// GetSizeInBytes() | ||
uint32_t GetMaxSizeInBytes() const; | ||
|
||
/// Write |data| into the buffer |offset| bytes from the start. Write | ||
/// |size_in_bytes| of data. | ||
Result SetDataWithOffset(const std::vector<Value>& data, uint32_t offset); | ||
|
@@ -188,6 +197,7 @@ class Buffer { | |
|
||
BufferType buffer_type_ = BufferType::kUnknown; | ||
std::string name_; | ||
uint32_t max_size_in_bytes_ = 0; | ||
uint32_t element_count_ = 0; | ||
uint32_t width_ = 0; | ||
uint32_t height_ = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -627,15 +627,15 @@ Result CommandParser::ProcessSSBO() { | |
((cmd->GetOffset() / buf->GetFormat()->SizeInBytes()) * | ||
buf->GetFormat()->InputNeededPerElement()) + | ||
static_cast<uint32_t>(values.size()); | ||
// The buffer should only be resized to become bigger. This means that if a | ||
// command was run to set the buffer size we'll honour that size until a | ||
// request happens to make the buffer bigger. | ||
if (value_count > buf->ValueCount()) | ||
buf->SetValueCount(value_count); | ||
|
||
// Even if the value count doesn't change, the buffer is still resized | ||
// because this maybe the first time data is set into the buffer. | ||
buf->SetSizeInBytes(buf->GetSizeInBytes()); | ||
uint32_t element_count = value_count; | ||
if (buf->GetFormat()->GetPackSize() == 0) { | ||
// This divides by the needed input values, not the values per element. | ||
// The assumption being the values coming in are read from the input, | ||
// where components are specified. The needed values maybe less then the | ||
// values per element. | ||
element_count = value_count / buf->GetFormat()->InputNeededPerElement(); | ||
} | ||
buf->SetMaxSizeInBytes(element_count * buf->GetFormat()->SizeInBytes()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new implementation allows the max-size-in-bytes to shrink. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right I forgot about this condition: |
||
|
||
cmd->SetValues(std::move(values)); | ||
|
||
|
@@ -789,20 +789,18 @@ Result CommandParser::ProcessUniform() { | |
if (!r.IsSuccess()) | ||
return r; | ||
|
||
// Multiply by the input needed because the value count will use the needed | ||
// input as the multiplier | ||
uint32_t value_count = ((cmd->GetOffset() / buf->GetFormat()->SizeInBytes()) * | ||
buf->GetFormat()->InputNeededPerElement()) + | ||
static_cast<uint32_t>(values.size()); | ||
// The buffer should only be resized to become bigger. This means that if a | ||
// command was run to set the buffer size we'll honour that size until a | ||
// request happens to make the buffer bigger. | ||
if (value_count > buf->ValueCount()) | ||
buf->SetValueCount(value_count); | ||
|
||
// Even if the value count doesn't change, the buffer is still resized | ||
// because this maybe the first time data is set into the buffer. | ||
buf->SetSizeInBytes(buf->GetSizeInBytes()); | ||
uint32_t element_count = value_count; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a repeat of the code sequence at the SSBO routine. That's a code smell that there's a common functionality should be refactored. By the look of it, it seems like all this should be a method on the buffer itself. Suggest defining There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not really resizing though. It is setting a fake size to be used in Dawn buffer creation. |
||
if (buf->GetFormat()->GetPackSize() == 0) { | ||
// This divides by the needed input values, not the values per element. | ||
// The assumption being the values coming in are read from the input, | ||
// where components are specified. The needed values maybe less then the | ||
// values per element. | ||
element_count = value_count / buf->GetFormat()->InputNeededPerElement(); | ||
} | ||
buf->SetMaxSizeInBytes(element_count * buf->GetFormat()->SizeInBytes()); | ||
|
||
if (cmd->IsPushConstant()) | ||
buf->SetData(values); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3339,7 +3339,7 @@ TEST_F(CommandParserTest, Uniform) { | |
const auto* buf = cmd->GetBuffer(); | ||
const auto* values = buf->GetValues<float>(); | ||
std::vector<float> results = {2.1f, 3.2f, 4.3f, 0.f}; | ||
EXPECT_TRUE(results.size() < buf->ValueCount()); | ||
EXPECT_EQ(results.size(), buf->ValueCount()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm glad this is sorted out. |
||
for (size_t i = 0; i < results.size(); ++i) { | ||
EXPECT_FLOAT_EQ(results[i], values[i]); | ||
} | ||
|
@@ -3381,7 +3381,7 @@ TEST_F(CommandParserTest, UniformWithContinuation) { | |
const auto* buf = cmd->GetBuffer(); | ||
const auto* values = buf->GetValues<float>(); | ||
std::vector<float> results = {2.1f, 3.2f, 4.3f, 0.f, 5.4f, 6.7f, 8.9f, 0.f}; | ||
EXPECT_TRUE(results.size() < buf->ValueCount()); | ||
EXPECT_EQ(results.size(), buf->ValueCount()); | ||
for (size_t i = 0; i < results.size(); ++i) { | ||
EXPECT_FLOAT_EQ(results[i], values[i]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Else not need since about always returns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set max_size_in_bytes_ in processSSBO/UBO while parsing, which means it stays at 0 for amber buffers. That why I return GetSizeInBytes() if it was zero (the comment in the header tries to explain this).