ValidationTest: Add helper to create a dummy renderpass
This commit is contained in:
parent
b343e8d920
commit
2dfea9961a
|
@ -23,12 +23,7 @@ static constexpr uint32_t kMaxVertexInputs = 16u;
|
|||
class InputStateTest : public ValidationTest {
|
||||
protected:
|
||||
nxt::RenderPipeline CreatePipeline(bool success, const nxt::InputState& inputState, std::string vertexSource) {
|
||||
nxt::RenderPass renderPass = AssertWillBeSuccess(device.CreateRenderPassBuilder())
|
||||
.SetAttachmentCount(1)
|
||||
.AttachmentSetFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetSubpassCount(1)
|
||||
.SubpassSetColorAttachment(0, 0, 0)
|
||||
.GetResult();
|
||||
DummyRenderPass renderpassData = CreateDummyRenderPass();
|
||||
|
||||
nxt::ShaderModuleBuilder vsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
|
||||
utils::FillShaderModuleBuilder(vsModuleBuilder, nxt::ShaderStage::Vertex, vertexSource.c_str());
|
||||
|
@ -51,7 +46,7 @@ class InputStateTest : public ValidationTest {
|
|||
builder = AssertWillBeError(device.CreateRenderPipelineBuilder());
|
||||
}
|
||||
|
||||
return builder.SetSubpass(renderPass, 0)
|
||||
return builder.SetSubpass(renderpassData.renderPass, 0)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetInputState(inputState)
|
||||
|
|
|
@ -95,3 +95,36 @@ void ValidationTest::OnBuilderErrorStatus(nxtBuilderErrorStatus status, const ch
|
|||
expectation.status = status;
|
||||
expectation.statusMessage = message;
|
||||
}
|
||||
|
||||
ValidationTest::DummyRenderPass ValidationTest::CreateDummyRenderPass() {
|
||||
DummyRenderPass dummy;
|
||||
dummy.width = 400;
|
||||
dummy.height = 400;
|
||||
dummy.attachmentFormat = nxt::TextureFormat::R8G8B8A8Unorm;
|
||||
|
||||
dummy.renderPass = AssertWillBeSuccess(device.CreateRenderPassBuilder())
|
||||
.SetAttachmentCount(1)
|
||||
.AttachmentSetFormat(0, dummy.attachmentFormat)
|
||||
.SetSubpassCount(1)
|
||||
.SubpassSetColorAttachment(0, 0, 0)
|
||||
.GetResult();
|
||||
|
||||
dummy.attachment = AssertWillBeSuccess(device.CreateTextureBuilder())
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
.SetExtent(dummy.width, dummy.height, 1)
|
||||
.SetFormat(dummy.attachmentFormat)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
dummy.attachment.FreezeUsage(nxt::TextureUsageBit::OutputAttachment);
|
||||
|
||||
nxt::TextureView view = AssertWillBeSuccess(dummy.attachment.CreateTextureViewBuilder()).GetResult();
|
||||
|
||||
dummy.framebuffer = AssertWillBeSuccess(device.CreateFramebufferBuilder())
|
||||
.SetRenderPass(dummy.renderPass)
|
||||
.SetAttachment(0, view)
|
||||
.SetDimensions(dummy.width, dummy.height)
|
||||
.GetResult();
|
||||
|
||||
return dummy;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ class ValidationTest : public testing::Test {
|
|||
ValidationTest();
|
||||
~ValidationTest();
|
||||
|
||||
void TearDown() override;
|
||||
|
||||
// Use these methods to add expectations on the validation of a builder. The expectations are
|
||||
// checked on test teardown. Adding an expectation is done like the following:
|
||||
//
|
||||
|
@ -46,7 +48,17 @@ class ValidationTest : public testing::Test {
|
|||
void StartExpectDeviceError();
|
||||
bool EndExpectDeviceError();
|
||||
|
||||
void TearDown() override;
|
||||
// Helper functions to create objects to test validation.
|
||||
|
||||
struct DummyRenderPass {
|
||||
nxt::RenderPass renderPass;
|
||||
nxt::Framebuffer framebuffer;
|
||||
nxt::Texture attachment;
|
||||
nxt::TextureFormat attachmentFormat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
DummyRenderPass CreateDummyRenderPass();
|
||||
|
||||
protected:
|
||||
nxt::Device device;
|
||||
|
@ -72,6 +84,8 @@ class ValidationTest : public testing::Test {
|
|||
static void OnBuilderErrorStatus(nxtBuilderErrorStatus status, const char* message, nxt::CallbackUserdata userdata1, nxt::CallbackUserdata userdata2);
|
||||
};
|
||||
|
||||
// Template implementation details
|
||||
|
||||
template<typename Builder>
|
||||
Builder ValidationTest::AssertWillBeSuccess(Builder builder, std::string debugName) {
|
||||
return AddExpectation(builder, debugName, true);
|
||||
|
|
Loading…
Reference in New Issue