mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Swap chains, part 2 (#94)
This commit is contained in:
@@ -21,7 +21,7 @@ class RenderPipelineValidationTest : public ValidationTest {
|
||||
void SetUp() override {
|
||||
ValidationTest::SetUp();
|
||||
|
||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||
CreateSimpleRenderPassAndFramebuffer(device, &renderpass, &framebuffer);
|
||||
|
||||
pipelineLayout = device.CreatePipelineLayoutBuilder().GetResult();
|
||||
|
||||
|
||||
@@ -69,6 +69,32 @@ bool ValidationTest::EndExpectDeviceError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
void ValidationTest::CreateSimpleRenderPassAndFramebuffer(const nxt::Device& device, nxt::RenderPass* renderpass, nxt::Framebuffer* framebuffer) {
|
||||
auto colorBuffer = device.CreateTextureBuilder()
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
.SetExtent(640, 480, 1)
|
||||
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
colorBuffer.FreezeUsage(nxt::TextureUsageBit::OutputAttachment);
|
||||
auto colorView = colorBuffer.CreateTextureViewBuilder()
|
||||
.GetResult();
|
||||
|
||||
*renderpass = device.CreateRenderPassBuilder()
|
||||
.SetAttachmentCount(1)
|
||||
.AttachmentSetFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetSubpassCount(1)
|
||||
.SubpassSetColorAttachment(0, 0, 0)
|
||||
.GetResult();
|
||||
|
||||
*framebuffer = device.CreateFramebufferBuilder()
|
||||
.SetRenderPass(*renderpass)
|
||||
.SetDimensions(640, 480)
|
||||
.SetAttachment(0, colorView)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
void ValidationTest::OnDeviceError(const char* message, nxtCallbackUserdata userdata) {
|
||||
// Skip this one specific error that is raised when a builder is used after it got an error
|
||||
// this is important because we don't want to wrap all creation tests in ASSERT_DEVICE_ERROR.
|
||||
|
||||
@@ -48,6 +48,8 @@ class ValidationTest : public testing::Test {
|
||||
void StartExpectDeviceError();
|
||||
bool EndExpectDeviceError();
|
||||
|
||||
void CreateSimpleRenderPassAndFramebuffer(const nxt::Device& device, nxt::RenderPass* renderpass, nxt::Framebuffer* framebuffer);
|
||||
|
||||
// Helper functions to create objects to test validation.
|
||||
|
||||
struct DummyRenderPass {
|
||||
|
||||
Reference in New Issue
Block a user