mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Change render passes from multi to single pass.
This as an API change to get closer to the direction in which WebGPU is headed. The API change in next.json caused a ton of files to be changed in the same commit to keep things compiling. API: the Framebuffer and RenderPass objects are now merged in a single RenderPassInfo that contains the attachments, loadOps and clear values for a BeginRenderPass command. The concept of subpass is removed. The RenderPass creation argument to RenderPipelines is replaced by explicitly setting the format of attachments for RenderPipeline. Validation: SetPipeline checks are changed to check that the attachments info set on a RenderPipeline matches the attachments of the render pass. Backends: Most changes are simplifications of the backends that no longer require and indirection to query the current subpass out of the render pass in BeginSubpass, and don't need to get the attachment info from a RenderPass when creating RenderPipelines. In the Vulkan backend, a VkRenderPass cache is added to reuse VkRenderPasses between RenderPassInfos and RenderPipelines. Tests and examples: they are updated with the simplified API. Tests specific to the Framebuffer and RenderPass objects were removed and validation tests for RenderPassInfo were added. Tested by running CppHelloTriangle on all backends, end2end tests on all platforms and all examples on the GL backend.
This commit is contained in:
committed by
Corentin Wallez
parent
87ec361cc2
commit
6f7749cce9
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
|
||||
#include "common/Constants.h"
|
||||
#include "utils/NXTHelpers.h"
|
||||
|
||||
class RenderPipelineValidationTest : public ValidationTest {
|
||||
@@ -21,7 +22,7 @@ class RenderPipelineValidationTest : public ValidationTest {
|
||||
void SetUp() override {
|
||||
ValidationTest::SetUp();
|
||||
|
||||
CreateSimpleRenderPassAndFramebuffer(device, &renderpass, &framebuffer);
|
||||
renderpass = CreateSimpleRenderPass();
|
||||
|
||||
pipelineLayout = device.CreatePipelineLayoutBuilder().GetResult();
|
||||
|
||||
@@ -45,7 +46,7 @@ class RenderPipelineValidationTest : public ValidationTest {
|
||||
}
|
||||
|
||||
nxt::RenderPipelineBuilder& AddDefaultStates(nxt::RenderPipelineBuilder&& builder) {
|
||||
builder.SetSubpass(renderpass, 0)
|
||||
builder.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
@@ -53,8 +54,7 @@ class RenderPipelineValidationTest : public ValidationTest {
|
||||
return builder;
|
||||
}
|
||||
|
||||
nxt::RenderPass renderpass;
|
||||
nxt::Framebuffer framebuffer;
|
||||
nxt::RenderPassInfo renderpass;
|
||||
nxt::ShaderModule vsModule;
|
||||
nxt::ShaderModule fsModule;
|
||||
nxt::InputState inputState;
|
||||
@@ -81,7 +81,7 @@ TEST_F(RenderPipelineValidationTest, CreationMissingProperty) {
|
||||
// Vertex stage not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetSubpass(renderpass, 0)
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
@@ -91,14 +91,14 @@ TEST_F(RenderPipelineValidationTest, CreationMissingProperty) {
|
||||
// Fragment stage not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetSubpass(renderpass, 0)
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Subpass not set
|
||||
// No attachment set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetLayout(pipelineLayout)
|
||||
@@ -112,47 +112,9 @@ TEST_F(RenderPipelineValidationTest, CreationMissingProperty) {
|
||||
TEST_F(RenderPipelineValidationTest, BlendState) {
|
||||
// Fails because blend state is set on a nonexistent color attachment
|
||||
{
|
||||
auto texture1 = device.CreateTextureBuilder()
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
.SetExtent(640, 480, 1)
|
||||
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
texture1.FreezeUsage(nxt::TextureUsageBit::OutputAttachment);
|
||||
auto textureView1 = texture1.CreateTextureViewBuilder()
|
||||
.GetResult();
|
||||
|
||||
auto texture2 = device.CreateTextureBuilder()
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
.SetExtent(640, 480, 1)
|
||||
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
texture2.FreezeUsage(nxt::TextureUsageBit::OutputAttachment);
|
||||
auto textureView2 = texture2.CreateTextureViewBuilder()
|
||||
.GetResult();
|
||||
|
||||
auto renderpass = device.CreateRenderPassBuilder()
|
||||
.SetAttachmentCount(2)
|
||||
.AttachmentSetFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.AttachmentSetFormat(1, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetSubpassCount(1)
|
||||
.SubpassSetColorAttachment(0, 0, 0)
|
||||
.GetResult();
|
||||
|
||||
auto framebuffer = device.CreateFramebufferBuilder()
|
||||
.SetRenderPass(renderpass)
|
||||
.SetDimensions(640, 480)
|
||||
.SetAttachment(0, textureView1)
|
||||
.SetAttachment(1, textureView2)
|
||||
.GetResult();
|
||||
|
||||
|
||||
// This one succeeds because attachment 0 is the subpass's color attachment
|
||||
// This one succeeds because attachment 0 is the color attachment
|
||||
AssertWillBeSuccess(device.CreateRenderPipelineBuilder())
|
||||
.SetSubpass(renderpass, 0)
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
@@ -160,9 +122,9 @@ TEST_F(RenderPipelineValidationTest, BlendState) {
|
||||
.SetColorAttachmentBlendState(0, blendState)
|
||||
.GetResult();
|
||||
|
||||
// This fails because attachment 1 is not one of the subpass's color attachments
|
||||
// This fails because attachment 1 is not one of the color attachments
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetSubpass(renderpass, 0)
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
@@ -174,7 +136,7 @@ TEST_F(RenderPipelineValidationTest, BlendState) {
|
||||
// Fails because color attachment is out of bounds
|
||||
{
|
||||
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
|
||||
.SetColorAttachmentBlendState(1, blendState)
|
||||
.SetColorAttachmentBlendState(kMaxColorAttachments, blendState)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -192,7 +154,7 @@ TEST_F(RenderPipelineValidationTest, DISABLED_TodoCreationMissingProperty) {
|
||||
// Fails because pipeline layout is not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetSubpass(renderpass, 0)
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
@@ -202,7 +164,7 @@ TEST_F(RenderPipelineValidationTest, DISABLED_TodoCreationMissingProperty) {
|
||||
// Fails because primitive topology is not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetSubpass(renderpass, 0)
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
@@ -240,13 +202,6 @@ TEST_F(RenderPipelineValidationTest, DISABLED_CreationDuplicates) {
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Fails because subpass is set twice
|
||||
{
|
||||
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
|
||||
.SetSubpass(renderpass, 0)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Fails because the layout is set twice
|
||||
{
|
||||
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
|
||||
|
||||
Reference in New Issue
Block a user