Use a descriptor for BindGroupLayout (#211)

* Use a descriptor for BindGroupLayout
* Fix MatchesLambda
* Add WireTests.StructureOfStructureArrayArgument
* Add BindGroupValidationTests.BindGroupLayoutCache
This commit is contained in:
Kai Ninomiya
2018-07-10 12:23:50 -07:00
committed by GitHub
parent 7883e7e59c
commit 234becf175
32 changed files with 259 additions and 163 deletions

View File

@@ -13,21 +13,23 @@
// limitations under the License.
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/NXTHelpers.h"
class BindGroupValidationTest : public ValidationTest {
};
TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto layout = device.CreateBindGroupLayoutBuilder()
.SetBindingsType(nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer, 0, 1)
.GetResult();
auto layout = utils::MakeBindGroupLayout(
device, {
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer},
});
auto buffer = device.CreateBufferBuilder()
.SetAllowedUsage(nxt::BufferUsageBit::Uniform)
.SetInitialUsage(nxt::BufferUsageBit::Uniform)
.SetSize(512)
.GetResult();
// Check that offset 0 is valid
{
auto bufferView = buffer.CreateBufferViewBuilder()
@@ -103,3 +105,21 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
.GetResult();
}
}
// This test verifies that the BindGroupLayout cache is successfully caching/deduplicating objects.
//
// NOTE: This test only works currently because unittests are run without the wire - so the returned
// BindGroupLayout pointers are actually visibly equivalent. With the wire, this would not be true.
TEST_F(BindGroupValidationTest, BindGroupLayoutCache) {
auto layout1 = utils::MakeBindGroupLayout(
device, {
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer},
});
auto layout2 = utils::MakeBindGroupLayout(
device, {
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer},
});
// Caching should cause these to be the same.
ASSERT_EQ(layout1.Get(), layout2.Get());
}