Adding multiple of 4 validation on indirect draws and dispatches
Bug: dawn:538 Change-Id: I6f4d8fb73a9fff910bdcd105f66299dc6afb61cd Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29761 Commit-Queue: Enrico Galli <enrico.galli@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
793a07e366
commit
1c25198384
|
@ -70,6 +70,10 @@ namespace dawn_native {
|
|||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
||||
|
||||
if (indirectOffset % 4 != 0) {
|
||||
return DAWN_VALIDATION_ERROR("Indirect offset must be a multiple of 4");
|
||||
}
|
||||
|
||||
if (indirectOffset >= indirectBuffer->GetSize() ||
|
||||
indirectOffset + kDispatchIndirectSize > indirectBuffer->GetSize()) {
|
||||
return DAWN_VALIDATION_ERROR("Indirect offset out of bounds");
|
||||
|
|
|
@ -88,6 +88,10 @@ namespace dawn_native {
|
|||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
||||
|
||||
if (indirectOffset % 4 != 0) {
|
||||
return DAWN_VALIDATION_ERROR("Indirect offset must be a multiple of 4");
|
||||
}
|
||||
|
||||
if (indirectOffset >= indirectBuffer->GetSize() ||
|
||||
indirectOffset + kDrawIndirectSize > indirectBuffer->GetSize()) {
|
||||
return DAWN_VALIDATION_ERROR("Indirect offset out of bounds");
|
||||
|
@ -108,6 +112,10 @@ namespace dawn_native {
|
|||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
||||
|
||||
if (indirectOffset % 4 != 0) {
|
||||
return DAWN_VALIDATION_ERROR("Indirect offset must be a multiple of 4");
|
||||
}
|
||||
|
||||
if ((indirectOffset >= indirectBuffer->GetSize() ||
|
||||
indirectOffset + kDrawIndexedIndirectSize > indirectBuffer->GetSize())) {
|
||||
return DAWN_VALIDATION_ERROR("Indirect offset out of bounds");
|
||||
|
|
|
@ -74,6 +74,10 @@ TEST_F(ComputeIndirectValidationTest, IndirectOffsetBounds) {
|
|||
// In bounds, bigger buffer, positive offset
|
||||
TestIndirectOffset(utils::Expectation::Success, {1, 2, 3, 4, 5, 6}, 3 * sizeof(uint32_t));
|
||||
|
||||
// In bounds, non-multiple of 4 offsets
|
||||
TestIndirectOffset(utils::Expectation::Failure, {1, 2, 3, 4}, 1);
|
||||
TestIndirectOffset(utils::Expectation::Failure, {1, 2, 3, 4}, 2);
|
||||
|
||||
// Out of bounds, buffer too small
|
||||
TestIndirectOffset(utils::Expectation::Failure, {1, 2}, 0);
|
||||
// Out of bounds, index too big
|
||||
|
|
|
@ -107,6 +107,10 @@ TEST_F(DrawIndirectValidationTest, DrawIndirectOffsetBounds) {
|
|||
TestIndirectOffsetDraw(utils::Expectation::Success, {1, 2, 3, 4, 5, 6, 7, 8},
|
||||
4 * sizeof(uint32_t));
|
||||
|
||||
// In bounds, non-multiple of 4 offsets
|
||||
TestIndirectOffsetDraw(utils::Expectation::Failure, {1, 2, 3, 4, 5}, 1);
|
||||
TestIndirectOffsetDraw(utils::Expectation::Failure, {1, 2, 3, 4, 5}, 2);
|
||||
|
||||
// Out of bounds, buffer too small
|
||||
TestIndirectOffsetDraw(utils::Expectation::Failure, {1, 2, 3}, 0);
|
||||
// Out of bounds, index too big
|
||||
|
@ -128,6 +132,10 @@ TEST_F(DrawIndirectValidationTest, DrawIndexedIndirectOffsetBounds) {
|
|||
TestIndirectOffsetDrawIndexed(utils::Expectation::Success, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
5 * sizeof(uint32_t));
|
||||
|
||||
// In bounds, non-multiple of 4 offsets
|
||||
TestIndirectOffsetDrawIndexed(utils::Expectation::Failure, {1, 2, 3, 4, 5, 6}, 1);
|
||||
TestIndirectOffsetDrawIndexed(utils::Expectation::Failure, {1, 2, 3, 4, 5, 6}, 2);
|
||||
|
||||
// Out of bounds, buffer too small
|
||||
TestIndirectOffsetDrawIndexed(utils::Expectation::Failure, {1, 2, 3, 4}, 0);
|
||||
// Out of bounds, index too big
|
||||
|
|
Loading…
Reference in New Issue