BindGroupLayout: Fix off-by-one kMaxBindingsPerGroup validation
BUG=chromium:906370 Change-Id: I95659856398523931b8aacf1e9a9239ac85f1156 Reviewed-on: https://dawn-review.googlesource.com/c/2567 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Shaobo Yan <shaobo.yan@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
ad3d9bafbc
commit
3a5e765f23
|
@ -35,7 +35,7 @@ namespace dawn_native {
|
||||||
DAWN_TRY(ValidateShaderStageBit(binding.visibility));
|
DAWN_TRY(ValidateShaderStageBit(binding.visibility));
|
||||||
DAWN_TRY(ValidateBindingType(binding.type));
|
DAWN_TRY(ValidateBindingType(binding.type));
|
||||||
|
|
||||||
if (binding.binding > kMaxBindingsPerGroup) {
|
if (binding.binding >= kMaxBindingsPerGroup) {
|
||||||
return DAWN_VALIDATION_ERROR("some binding index exceeds the maximum value");
|
return DAWN_VALIDATION_ERROR("some binding index exceeds the maximum value");
|
||||||
}
|
}
|
||||||
if (bindingsSet[binding.binding]) {
|
if (bindingsSet[binding.binding]) {
|
||||||
|
|
|
@ -13,11 +13,14 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
|
#include "common/Constants.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/DawnHelpers.h"
|
||||||
|
|
||||||
class BindGroupValidationTest : public ValidationTest {
|
class BindGroupValidationTest : public ValidationTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Tests constraints on the buffer view offset for bind groups.
|
||||||
TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||||
auto layout = utils::MakeBindGroupLayout(
|
auto layout = utils::MakeBindGroupLayout(
|
||||||
device, {
|
device, {
|
||||||
|
@ -129,3 +132,16 @@ TEST_F(BindGroupValidationTest, BindGroupBinding) {
|
||||||
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests setting OOB checks for kMaxBindingsPerGroup in bind group layouts.
|
||||||
|
TEST_F(BindGroupValidationTest, BindGroupLayoutBindingOOB) {
|
||||||
|
// Checks that kMaxBindingsPerGroup - 1 is valid.
|
||||||
|
utils::MakeBindGroupLayout(device, {
|
||||||
|
{kMaxBindingsPerGroup - 1, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Checks that kMaxBindingsPerGroup is OOB
|
||||||
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(device, {
|
||||||
|
{kMaxBindingsPerGroup, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue