Fix framebuffer dimensions in InputStateTest
Also add validation that the framebuffer size matches its attachement size and make a test for it.
This commit is contained in:
parent
0b186b1fda
commit
de4a3c4c3b
|
@ -75,6 +75,14 @@ namespace backend {
|
|||
return nullptr;
|
||||
}
|
||||
usingBackbufferHack = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO(cwallez@chromium.org): Adjust for the mip-level once that is supported.
|
||||
if (textureView->GetTexture()->GetWidth() != width ||
|
||||
textureView->GetTexture()->GetHeight() != height) {
|
||||
HandleError("Framebuffer size doesn't match attachment size");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class InputStateTest : public NXTTest {
|
|||
framebuffer = device.CreateFramebufferBuilder()
|
||||
.SetRenderPass(renderpass)
|
||||
.SetAttachment(0, renderTargetView)
|
||||
.SetDimensions(640, 480)
|
||||
.SetDimensions(400, 400)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ class InputStateTest : public NXTTest {
|
|||
}
|
||||
|
||||
nxt::CommandBuffer commands = builder
|
||||
.DrawArrays(triangles * 4, instances, 0, 0)
|
||||
.DrawArrays(triangles * 3, instances, 0, 0)
|
||||
.EndRenderSubpass()
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
|
|
|
@ -15,6 +15,20 @@
|
|||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
|
||||
class FramebufferValidationTest : public ValidationTest {
|
||||
protected:
|
||||
nxt::TextureView Create2DAttachment(uint32_t width, uint32_t height, nxt::TextureFormat format) {
|
||||
nxt::Texture attachment = device.CreateTextureBuilder()
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
.SetExtent(width, height, 1)
|
||||
.SetFormat(format)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.SetInitialUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
|
||||
return attachment.CreateTextureViewBuilder()
|
||||
.GetResult();
|
||||
}
|
||||
};
|
||||
|
||||
// Test for an empty framebuffer builder
|
||||
|
@ -64,3 +78,46 @@ TEST_F(FramebufferValidationTest, BasicWithEmptyAttachment) {
|
|||
.SetDimensions(100, 100)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Check validation that the attachment size must be the same as the framebuffer size.
|
||||
// TODO(cwallez@chromium.org): Investigate this constraint more, for example Vulkan requires
|
||||
// that the attachment sizes are *at least* the framebuffer size.
|
||||
TEST_F(FramebufferValidationTest, AttachmentSizeMatchFramebufferSize) {
|
||||
auto renderpass = AssertWillBeSuccess(device.CreateRenderPassBuilder())
|
||||
.SetAttachmentCount(1)
|
||||
.AttachmentSetFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetSubpassCount(1)
|
||||
.SubpassSetColorAttachment(0, 0, 0)
|
||||
.GetResult();
|
||||
|
||||
nxt::TextureView attachment = Create2DAttachment(100, 100, nxt::TextureFormat::R8G8B8A8Unorm);
|
||||
|
||||
// Control case: two attachments of the same size
|
||||
{
|
||||
auto framebuffer = AssertWillBeSuccess(device.CreateFramebufferBuilder())
|
||||
.SetRenderPass(renderpass)
|
||||
.SetAttachment(0, attachment)
|
||||
.SetDimensions(100, 100)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Error: case, size mismatch (framebuffer bigger than attachments)
|
||||
{
|
||||
auto framebuffer = AssertWillBeError(device.CreateFramebufferBuilder())
|
||||
.SetRenderPass(renderpass)
|
||||
.SetAttachment(0, attachment)
|
||||
.SetDimensions(200, 200)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Error: case, size mismatch (framebuffer smaller than attachments)
|
||||
{
|
||||
auto framebuffer = AssertWillBeError(device.CreateFramebufferBuilder())
|
||||
.SetRenderPass(renderpass)
|
||||
.SetAttachment(0, attachment)
|
||||
.SetDimensions(50, 50)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// TODO(cwallez@chromium.org): also test with a mismatches depth / stencil
|
||||
}
|
Loading…
Reference in New Issue