mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
dawn_native: Move beginRenderPass texture usage validation into the encoder
In a future CL the PassResourceUsage structure will become a SyncScopeResourceUsage and will be used to validate at each synchronization scope. For separation of concerns, the validation that resource have the correct usage shouldn't be done at the sync scope level but at each entrypoint that uses the resource. The validation tests had missing coverage of usage validation for BeginRenderPass so validation tests are added. (Storage and Sampled are validated at bindgroup creation and already had validation tests) Bug: dawn:635 Change-Id: I36488c2d0222c4799476adf06c1c734989b1a158 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38381 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
7479128589
commit
72cd1a5e89
@@ -146,6 +146,29 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the render pass color attachment must have the RenderAttachment usage.
|
||||
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentInvalidUsage) {
|
||||
// Control case: using a texture with RenderAttachment is valid.
|
||||
{
|
||||
wgpu::TextureView renderView =
|
||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
||||
utils::ComboRenderPassDescriptor renderPass({renderView});
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Error case: using a texture with Sampled is invalid.
|
||||
{
|
||||
wgpu::TextureDescriptor texDesc;
|
||||
texDesc.usage = wgpu::TextureUsage::Sampled;
|
||||
texDesc.size = {1, 1, 1};
|
||||
texDesc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
wgpu::Texture sampledTex = device.CreateTexture(&texDesc);
|
||||
|
||||
utils::ComboRenderPassDescriptor renderPass({sampledTex.CreateView()});
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// Attachments must have the same size
|
||||
TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
|
||||
wgpu::TextureView color1x1A =
|
||||
@@ -344,6 +367,30 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the render pass depth attachment must have the RenderAttachment usage.
|
||||
TEST_F(RenderPassDescriptorValidationTest, DepthAttachmentInvalidUsage) {
|
||||
// Control case: using a texture with RenderAttachment is valid.
|
||||
{
|
||||
wgpu::TextureView renderView =
|
||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth32Float);
|
||||
utils::ComboRenderPassDescriptor renderPass({}, renderView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Error case: using a texture with Sampled is invalid.
|
||||
{
|
||||
wgpu::TextureDescriptor texDesc;
|
||||
texDesc.usage = wgpu::TextureUsage::Sampled;
|
||||
texDesc.size = {1, 1, 1};
|
||||
texDesc.format = wgpu::TextureFormat::Depth32Float;
|
||||
wgpu::Texture sampledTex = device.CreateTexture(&texDesc);
|
||||
wgpu::TextureView sampledView = sampledTex.CreateView();
|
||||
|
||||
utils::ComboRenderPassDescriptor renderPass({}, sampledView);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// Only 2D texture views with mipLevelCount == 1 are allowed to be color attachments
|
||||
TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepthStencil) {
|
||||
constexpr uint32_t kArrayLayers = 1;
|
||||
|
||||
Reference in New Issue
Block a user