mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-03 19:55:56 +00:00
Newline fixes and tiny cleanups for lazy-0-init
BUG= Change-Id: I1165b0d75b4e2796ff89ffabb2401c474955ee2a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8440 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Natasha Lee <natlee@microsoft.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
431d618961
commit
773a551d1a
@ -175,7 +175,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
dawn::LoadOp loadOp = attachmentInfo.loadOp;
|
dawn::LoadOp loadOp = attachmentInfo.loadOp;
|
||||||
ASSERT(view->GetLayerCount() == 1);
|
ASSERT(view->GetLayerCount() == 1);
|
||||||
ASSERT(view->GetLevelCount() == 1);
|
ASSERT(view->GetLevelCount() == 1);
|
||||||
if (loadOp == dawn::LoadOp::Load && view->GetTexture() &&
|
if (loadOp == dawn::LoadOp::Load &&
|
||||||
!view->GetTexture()->IsSubresourceContentInitialized(
|
!view->GetTexture()->IsSubresourceContentInitialized(
|
||||||
view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1)) {
|
view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1)) {
|
||||||
loadOp = dawn::LoadOp::Clear;
|
loadOp = dawn::LoadOp::Clear;
|
||||||
|
@ -1,106 +1,106 @@
|
|||||||
// Copyright 2019 The Dawn Authors
|
// Copyright 2019 The Dawn Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/DawnHelpers.h"
|
||||||
|
|
||||||
class NonzeroTextureCreationTests : public DawnTest {
|
class NonzeroTextureCreationTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
DawnTest::SetUp();
|
DawnTest::SetUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr static uint32_t kSize = 128;
|
constexpr static uint32_t kSize = 128;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test that texture clears to 1's because toggle is enabled.
|
// Test that texture clears to 1's because toggle is enabled.
|
||||||
TEST_P(NonzeroTextureCreationTests, TextureCreationClearsOneBits) {
|
TEST_P(NonzeroTextureCreationTests, TextureCreationClearsOneBits) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.size.width = kSize;
|
descriptor.size.width = kSize;
|
||||||
descriptor.size.height = kSize;
|
descriptor.size.height = kSize;
|
||||||
descriptor.size.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
RGBA8 filledWithOnes(255, 255, 255, 255);
|
RGBA8 filledWithOnes(255, 255, 255, 255);
|
||||||
EXPECT_PIXEL_RGBA8_EQ(filledWithOnes, texture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(filledWithOnes, texture, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that non-zero mip level clears to 1's because toggle is enabled.
|
// Test that non-zero mip level clears to 1's because toggle is enabled.
|
||||||
TEST_P(NonzeroTextureCreationTests, MipMapClears) {
|
TEST_P(NonzeroTextureCreationTests, MipMapClears) {
|
||||||
constexpr uint32_t mipLevels = 4;
|
constexpr uint32_t mipLevels = 4;
|
||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.size.width = kSize;
|
descriptor.size.width = kSize;
|
||||||
descriptor.size.height = kSize;
|
descriptor.size.height = kSize;
|
||||||
descriptor.size.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = mipLevels;
|
descriptor.mipLevelCount = mipLevels;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
std::vector<RGBA8> expected;
|
std::vector<RGBA8> expected;
|
||||||
RGBA8 filledWithOnes(255, 255, 255, 255);
|
RGBA8 filledWithOnes(255, 255, 255, 255);
|
||||||
for (uint32_t i = 0; i < kSize * kSize; ++i) {
|
for (uint32_t i = 0; i < kSize * kSize; ++i) {
|
||||||
expected.push_back(filledWithOnes);
|
expected.push_back(filledWithOnes);
|
||||||
}
|
}
|
||||||
uint32_t mipSize = kSize >> 2;
|
uint32_t mipSize = kSize >> 2;
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, mipSize, mipSize, 2, 0);
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, mipSize, mipSize, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that non-zero array layers clears to 1's because toggle is enabled.
|
// Test that non-zero array layers clears to 1's because toggle is enabled.
|
||||||
TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) {
|
TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) {
|
||||||
constexpr uint32_t arrayLayers = 4;
|
constexpr uint32_t arrayLayers = 4;
|
||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.size.width = kSize;
|
descriptor.size.width = kSize;
|
||||||
descriptor.size.height = kSize;
|
descriptor.size.height = kSize;
|
||||||
descriptor.size.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayerCount = arrayLayers;
|
descriptor.arrayLayerCount = arrayLayers;
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
std::vector<RGBA8> expected;
|
std::vector<RGBA8> expected;
|
||||||
RGBA8 filledWithOnes(255, 255, 255, 255);
|
RGBA8 filledWithOnes(255, 255, 255, 255);
|
||||||
for (uint32_t i = 0; i < kSize * kSize; ++i) {
|
for (uint32_t i = 0; i < kSize * kSize; ++i) {
|
||||||
expected.push_back(filledWithOnes);
|
expected.push_back(filledWithOnes);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, kSize, kSize, 0, 2);
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, kSize, kSize, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(NonzeroTextureCreationTests,
|
DAWN_INSTANTIATE_TEST(NonzeroTextureCreationTests,
|
||||||
ForceWorkarounds(D3D12Backend,
|
ForceWorkarounds(D3D12Backend,
|
||||||
{"nonzero_clear_resources_on_creation_for_testing"},
|
{"nonzero_clear_resources_on_creation_for_testing"},
|
||||||
{"lazy_clear_resource_on_first_use"}),
|
{"lazy_clear_resource_on_first_use"}),
|
||||||
ForceWorkarounds(OpenGLBackend,
|
ForceWorkarounds(OpenGLBackend,
|
||||||
{"nonzero_clear_resources_on_creation_for_testing"},
|
{"nonzero_clear_resources_on_creation_for_testing"},
|
||||||
{"lazy_clear_resource_on_first_use"}),
|
{"lazy_clear_resource_on_first_use"}),
|
||||||
ForceWorkarounds(VulkanBackend,
|
ForceWorkarounds(VulkanBackend,
|
||||||
{"nonzero_clear_resources_on_creation_for_testing"},
|
{"nonzero_clear_resources_on_creation_for_testing"},
|
||||||
{"lazy_clear_resource_on_first_use"}));
|
{"lazy_clear_resource_on_first_use"}));
|
||||||
|
@ -1,406 +1,410 @@
|
|||||||
// Copyright 2019 The Dawn Authors
|
// Copyright 2019 The Dawn Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/DawnHelpers.h"
|
||||||
|
|
||||||
class TextureZeroInitTest : public DawnTest {
|
class TextureZeroInitTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
DawnTest::SetUp();
|
DawnTest::SetUp();
|
||||||
}
|
}
|
||||||
dawn::TextureDescriptor CreateTextureDescriptor(uint32_t mipLevelCount,
|
dawn::TextureDescriptor CreateTextureDescriptor(uint32_t mipLevelCount,
|
||||||
uint32_t arrayLayerCount,
|
uint32_t arrayLayerCount,
|
||||||
dawn::TextureUsageBit usage,
|
dawn::TextureUsageBit usage,
|
||||||
dawn::TextureFormat format) {
|
dawn::TextureFormat format) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.size.width = kSize;
|
descriptor.size.width = kSize;
|
||||||
descriptor.size.height = kSize;
|
descriptor.size.height = kSize;
|
||||||
descriptor.size.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayerCount = arrayLayerCount;
|
descriptor.arrayLayerCount = arrayLayerCount;
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
descriptor.mipLevelCount = mipLevelCount;
|
descriptor.mipLevelCount = mipLevelCount;
|
||||||
descriptor.usage = usage;
|
descriptor.usage = usage;
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
dawn::TextureViewDescriptor CreateTextureViewDescriptor(uint32_t baseMipLevel,
|
dawn::TextureViewDescriptor CreateTextureViewDescriptor(uint32_t baseMipLevel,
|
||||||
uint32_t baseArrayLayer) {
|
uint32_t baseArrayLayer) {
|
||||||
dawn::TextureViewDescriptor descriptor;
|
dawn::TextureViewDescriptor descriptor;
|
||||||
descriptor.format = kColorFormat;
|
descriptor.format = kColorFormat;
|
||||||
descriptor.baseArrayLayer = baseArrayLayer;
|
descriptor.baseArrayLayer = baseArrayLayer;
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
descriptor.baseMipLevel = baseMipLevel;
|
descriptor.baseMipLevel = baseMipLevel;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.dimension = dawn::TextureViewDimension::e2D;
|
descriptor.dimension = dawn::TextureViewDimension::e2D;
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
dawn::RenderPipeline CreatePipelineForTest() {
|
dawn::RenderPipeline CreatePipelineForTest() {
|
||||||
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
|
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
|
||||||
const char* vs =
|
const char* vs =
|
||||||
R"(#version 450
|
R"(#version 450
|
||||||
const vec3 pos[6] = vec3[6](vec3(-1.0f, -1.0f, 0.0f),
|
const vec2 pos[6] = vec2[6](vec2(-1.0f, -1.0f),
|
||||||
vec3(-1.0f, 1.0f, 0.0f),
|
vec2(-1.0f, 1.0f),
|
||||||
vec3( 1.0f, -1.0f, 0.0f),
|
vec2( 1.0f, -1.0f),
|
||||||
vec3( 1.0f, 1.0f, 0.0f),
|
vec2( 1.0f, 1.0f),
|
||||||
vec3(-1.0f, 1.0f, 0.0f),
|
vec2(-1.0f, 1.0f),
|
||||||
vec3( 1.0f, -1.0f, 0.0f)
|
vec2( 1.0f, -1.0f)
|
||||||
);
|
);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(pos[gl_VertexIndex], 1.0);
|
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
|
||||||
})";
|
})";
|
||||||
pipelineDescriptor.cVertexStage.module =
|
pipelineDescriptor.cVertexStage.module =
|
||||||
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs);
|
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs);
|
||||||
|
|
||||||
const char* fs =
|
const char* fs =
|
||||||
"#version 450\n"
|
"#version 450\n"
|
||||||
"layout(location = 0) out vec4 fragColor;"
|
"layout(location = 0) out vec4 fragColor;"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
pipelineDescriptor.cFragmentStage.module =
|
pipelineDescriptor.cFragmentStage.module =
|
||||||
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs);
|
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs);
|
||||||
|
|
||||||
pipelineDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Equal;
|
pipelineDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Equal;
|
||||||
pipelineDescriptor.cDepthStencilState.stencilFront.compare = dawn::CompareFunction::Equal;
|
pipelineDescriptor.cDepthStencilState.stencilFront.compare = dawn::CompareFunction::Equal;
|
||||||
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState;
|
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState;
|
||||||
|
|
||||||
return device.CreateRenderPipeline(&pipelineDescriptor);
|
return device.CreateRenderPipeline(&pipelineDescriptor);
|
||||||
}
|
}
|
||||||
constexpr static uint32_t kSize = 128;
|
constexpr static uint32_t kSize = 128;
|
||||||
constexpr static dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm;
|
constexpr static dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm;
|
||||||
constexpr static dawn::TextureFormat kDepthStencilFormat =
|
constexpr static dawn::TextureFormat kDepthStencilFormat =
|
||||||
dawn::TextureFormat::Depth24PlusStencil8;
|
dawn::TextureFormat::Depth24PlusStencil8;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This tests that the code path of CopyTextureToBuffer clears correctly to Zero after first usage
|
// This tests that the code path of CopyTextureToBuffer clears correctly to Zero after first usage
|
||||||
TEST_P(TextureZeroInitTest, RecycleTextureMemoryClear) {
|
TEST_P(TextureZeroInitTest, CopyTextureToBufferSource) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
// Texture's first usage is in EXPECT_PIXEL_RGBA8_EQ's call to CopyTextureToBuffer
|
// Texture's first usage is in EXPECT_PIXEL_RGBA8_EQ's call to CopyTextureToBuffer
|
||||||
RGBA8 filledWithZeros(0, 0, 0, 0);
|
RGBA8 filledWithZeros(0, 0, 0, 0);
|
||||||
EXPECT_PIXEL_RGBA8_EQ(filledWithZeros, texture, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(filledWithZeros, texture, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that non-zero mip level clears subresource to Zero after first use
|
// Test that non-zero mip level clears subresource to Zero after first use
|
||||||
// This goes through the BeginRenderPass's code path
|
// This goes through the BeginRenderPass's code path
|
||||||
TEST_P(TextureZeroInitTest, MipMapClearsToZero) {
|
TEST_P(TextureZeroInitTest, RenderingMipMapClearsToZero) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
4, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
4, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(2, 0);
|
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(2, 0);
|
||||||
dawn::TextureView view = texture.CreateView(&viewDescriptor);
|
dawn::TextureView view = texture.CreateView(&viewDescriptor);
|
||||||
|
|
||||||
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
|
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
|
||||||
|
|
||||||
renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->attachment = view;
|
renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->attachment = view;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
{
|
{
|
||||||
// Texture's first usage is in BeginRenderPass's call to RecordRenderPass
|
// Texture's first usage is in BeginRenderPass's call to RecordRenderPass
|
||||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||||
pass.EndPass();
|
pass.EndPass();
|
||||||
}
|
}
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
|
|
||||||
uint32_t mipSize = kSize >> 2;
|
uint32_t mipSize = kSize >> 2;
|
||||||
std::vector<RGBA8> expected(mipSize * mipSize, {0, 0, 0, 0});
|
std::vector<RGBA8> expected(mipSize * mipSize, {0, 0, 0, 0});
|
||||||
|
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), renderPass.color, 0, 0, mipSize, mipSize, 2, 0);
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), renderPass.color, 0, 0, mipSize, mipSize, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that non-zero array layers clears subresource to Zero after first use.
|
// Test that non-zero array layers clears subresource to Zero after first use.
|
||||||
// This goes through the BeginRenderPass's code path
|
// This goes through the BeginRenderPass's code path
|
||||||
TEST_P(TextureZeroInitTest, ArrayLayerClearsToZero) {
|
TEST_P(TextureZeroInitTest, RenderingArrayLayerClearsToZero) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
1, 4, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
1, 4, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(0, 2);
|
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(0, 2);
|
||||||
dawn::TextureView view = texture.CreateView(&viewDescriptor);
|
dawn::TextureView view = texture.CreateView(&viewDescriptor);
|
||||||
|
|
||||||
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
|
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
|
||||||
|
|
||||||
renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->attachment = view;
|
renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->attachment = view;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
{
|
{
|
||||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||||
pass.EndPass();
|
pass.EndPass();
|
||||||
}
|
}
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
|
|
||||||
std::vector<RGBA8> expected(kSize * kSize, {0, 0, 0, 0});
|
std::vector<RGBA8> expected(kSize * kSize, {0, 0, 0, 0});
|
||||||
|
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), renderPass.color, 0, 0, kSize, kSize, 0, 2);
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), renderPass.color, 0, 0, kSize, kSize, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This tests CopyBufferToTexture fully overwrites copy so lazy init is not needed.
|
// This tests CopyBufferToTexture fully overwrites copy so lazy init is not needed.
|
||||||
// TODO(natlee@microsoft.com): Add backdoor to dawn native to query the number of zero-inited
|
// TODO(natlee@microsoft.com): Add backdoor to dawn native to query the number of zero-inited
|
||||||
// subresources
|
// subresources
|
||||||
TEST_P(TextureZeroInitTest, CopyBufferToTexture) {
|
TEST_P(TextureZeroInitTest, CopyBufferToTexture) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
4, 1,
|
4, 1,
|
||||||
dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled |
|
dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled |
|
||||||
dawn::TextureUsageBit::TransferSrc,
|
dawn::TextureUsageBit::TransferSrc,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::TransferSrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::TransferSrc);
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
dawn::Extent3D copySize = {kSize, kSize, 1};
|
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::Extent3D copySize = {kSize, kSize, 1};
|
||||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
queue.Submit(1, &commands);
|
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||||
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
std::vector<RGBA8> expected(kSize * kSize, {100, 100, 100, 100});
|
queue.Submit(1, &commands);
|
||||||
|
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, kSize, kSize, 0, 0);
|
std::vector<RGBA8> expected(kSize * kSize, {100, 100, 100, 100});
|
||||||
}
|
|
||||||
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, kSize, kSize, 0, 0);
|
||||||
// Test for a copy only to a subset of the subresource, lazy init is necessary to clear the other
|
}
|
||||||
// half.
|
|
||||||
TEST_P(TextureZeroInitTest, CopyBufferToTextureHalf) {
|
// Test for a copy only to a subset of the subresource, lazy init is necessary to clear the other
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
// half.
|
||||||
4, 1,
|
TEST_P(TextureZeroInitTest, CopyBufferToTextureHalf) {
|
||||||
dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled |
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
dawn::TextureUsageBit::TransferSrc,
|
4, 1,
|
||||||
kColorFormat);
|
dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled |
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::TextureUsageBit::TransferSrc,
|
||||||
|
kColorFormat);
|
||||||
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::TransferSrc);
|
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::TransferSrc);
|
||||||
dawn::Extent3D copySize = {kSize / 2, kSize, 1};
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
dawn::Extent3D copySize = {kSize / 2, kSize, 1};
|
||||||
queue.Submit(1, &commands);
|
|
||||||
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
std::vector<RGBA8> expected100((kSize / 2) * kSize, {100, 100, 100, 100});
|
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||||
std::vector<RGBA8> expectedZeros((kSize / 2) * kSize, {0, 0, 0, 0});
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
// first half filled with 100, by the buffer data
|
queue.Submit(1, &commands);
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected100.data(), texture, 0, 0, kSize / 2, kSize, 0, 0);
|
|
||||||
// second half should be cleared
|
std::vector<RGBA8> expected100((kSize / 2) * kSize, {100, 100, 100, 100});
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expectedZeros.data(), texture, kSize / 2, 0, kSize / 2, kSize, 0, 0);
|
std::vector<RGBA8> expectedZeros((kSize / 2) * kSize, {0, 0, 0, 0});
|
||||||
}
|
// first half filled with 100, by the buffer data
|
||||||
|
EXPECT_TEXTURE_RGBA8_EQ(expected100.data(), texture, 0, 0, kSize / 2, kSize, 0, 0);
|
||||||
// This tests CopyTextureToTexture fully overwrites copy so lazy init is not needed.
|
// second half should be cleared
|
||||||
TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
|
EXPECT_TEXTURE_RGBA8_EQ(expectedZeros.data(), texture, kSize / 2, 0, kSize / 2, kSize, 0, 0);
|
||||||
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
}
|
||||||
1, 1, dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::TransferSrc, kColorFormat);
|
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
// This tests CopyTextureToTexture fully overwrites copy so lazy init is not needed.
|
||||||
|
TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
|
||||||
dawn::TextureCopyView srcTextureCopyView =
|
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
||||||
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
1, 1, dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::TransferSrc, kColorFormat);
|
||||||
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
dawn::TextureDescriptor dstDescriptor = CreateTextureDescriptor(
|
|
||||||
1, 1,
|
dawn::TextureCopyView srcTextureCopyView =
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferDst |
|
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
||||||
dawn::TextureUsageBit::TransferSrc,
|
|
||||||
kColorFormat);
|
dawn::TextureDescriptor dstDescriptor = CreateTextureDescriptor(
|
||||||
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
1, 1,
|
||||||
|
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferDst |
|
||||||
dawn::TextureCopyView dstTextureCopyView =
|
dawn::TextureUsageBit::TransferSrc,
|
||||||
utils::CreateTextureCopyView(dstTexture, 0, 0, {0, 0, 0});
|
kColorFormat);
|
||||||
|
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
||||||
dawn::Extent3D copySize = {kSize, kSize, 1};
|
|
||||||
|
dawn::TextureCopyView dstTextureCopyView =
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
utils::CreateTextureCopyView(dstTexture, 0, 0, {0, 0, 0});
|
||||||
encoder.CopyTextureToTexture(&srcTextureCopyView, &dstTextureCopyView, ©Size);
|
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
dawn::Extent3D copySize = {kSize, kSize, 1};
|
||||||
queue.Submit(1, &commands);
|
|
||||||
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
std::vector<RGBA8> expected(kSize * kSize, {0, 0, 0, 0});
|
encoder.CopyTextureToTexture(&srcTextureCopyView, &dstTextureCopyView, ©Size);
|
||||||
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
queue.Submit(1, &commands);
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), dstTexture, 0, 0, kSize, kSize, 0, 0);
|
|
||||||
}
|
std::vector<RGBA8> expected(kSize * kSize, {0, 0, 0, 0});
|
||||||
|
|
||||||
// This Tests the CopyTextureToTexture's copy only to a subset of the subresource, lazy init is
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
||||||
// necessary to clear the other half.
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), dstTexture, 0, 0, kSize, kSize, 0, 0);
|
||||||
TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
|
}
|
||||||
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
|
||||||
1, 1,
|
// This Tests the CopyTextureToTexture's copy only to a subset of the subresource, lazy init is
|
||||||
dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::TransferSrc |
|
// necessary to clear the other half.
|
||||||
dawn::TextureUsageBit::TransferDst,
|
TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
|
||||||
kColorFormat);
|
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
1, 1,
|
||||||
|
dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::TransferSrc |
|
||||||
// fill srcTexture with 100
|
dawn::TextureUsageBit::TransferDst,
|
||||||
{
|
kColorFormat);
|
||||||
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
dawn::Buffer stagingBuffer =
|
|
||||||
utils::CreateBufferFromData(device, data.data(), static_cast<uint32_t>(data.size()),
|
// fill srcTexture with 100
|
||||||
dawn::BufferUsageBit::TransferSrc);
|
{
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::Buffer stagingBuffer =
|
||||||
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
utils::CreateBufferFromData(device, data.data(), static_cast<uint32_t>(data.size()),
|
||||||
dawn::Extent3D copySize = {kSize, kSize, 1};
|
dawn::BufferUsageBit::TransferSrc);
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
dawn::TextureCopyView textureCopyView =
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
||||||
queue.Submit(1, &commands);
|
dawn::Extent3D copySize = {kSize, kSize, 1};
|
||||||
}
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||||
dawn::TextureCopyView srcTextureCopyView =
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
queue.Submit(1, &commands);
|
||||||
|
}
|
||||||
dawn::TextureDescriptor dstDescriptor = CreateTextureDescriptor(
|
|
||||||
1, 1,
|
dawn::TextureCopyView srcTextureCopyView =
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferDst |
|
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
||||||
dawn::TextureUsageBit::TransferSrc,
|
|
||||||
kColorFormat);
|
dawn::TextureDescriptor dstDescriptor = CreateTextureDescriptor(
|
||||||
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
1, 1,
|
||||||
|
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferDst |
|
||||||
dawn::TextureCopyView dstTextureCopyView =
|
dawn::TextureUsageBit::TransferSrc,
|
||||||
utils::CreateTextureCopyView(dstTexture, 0, 0, {0, 0, 0});
|
kColorFormat);
|
||||||
dawn::Extent3D copySize = {kSize / 2, kSize, 1};
|
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::TextureCopyView dstTextureCopyView =
|
||||||
encoder.CopyTextureToTexture(&srcTextureCopyView, &dstTextureCopyView, ©Size);
|
utils::CreateTextureCopyView(dstTexture, 0, 0, {0, 0, 0});
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
dawn::Extent3D copySize = {kSize / 2, kSize, 1};
|
||||||
queue.Submit(1, &commands);
|
|
||||||
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
std::vector<RGBA8> expectedWithZeros((kSize / 2) * kSize, {0, 0, 0, 0});
|
encoder.CopyTextureToTexture(&srcTextureCopyView, &dstTextureCopyView, ©Size);
|
||||||
std::vector<RGBA8> expectedWith100(kSize * kSize, {100, 100, 100, 100});
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
|
queue.Submit(1, &commands);
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expectedWith100.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expectedWith100.data(), dstTexture, 0, 0, kSize / 2, kSize, 0, 0);
|
std::vector<RGBA8> expectedWithZeros((kSize / 2) * kSize, {0, 0, 0, 0});
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expectedWithZeros.data(), dstTexture, kSize / 2, 0, kSize / 2, kSize, 0,
|
std::vector<RGBA8> expectedWith100(kSize * kSize, {100, 100, 100, 100});
|
||||||
0);
|
|
||||||
}
|
EXPECT_TEXTURE_RGBA8_EQ(expectedWith100.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
||||||
|
EXPECT_TEXTURE_RGBA8_EQ(expectedWith100.data(), dstTexture, 0, 0, kSize / 2, kSize, 0, 0);
|
||||||
// This tests the texture with depth attachment and load op load will init depth stencil texture to
|
EXPECT_TEXTURE_RGBA8_EQ(expectedWithZeros.data(), dstTexture, kSize / 2, 0, kSize / 2, kSize, 0,
|
||||||
// 0s.
|
0);
|
||||||
TEST_P(TextureZeroInitTest, DepthClear) {
|
}
|
||||||
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
|
||||||
1, 1,
|
// This tests the texture with depth attachment and load op load will init depth stencil texture to
|
||||||
dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::TransferDst |
|
// 0s.
|
||||||
dawn::TextureUsageBit::OutputAttachment,
|
TEST_P(TextureZeroInitTest, RenderingLoadingDepth) {
|
||||||
kColorFormat);
|
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
1, 1,
|
||||||
|
dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::TransferDst |
|
||||||
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
dawn::TextureUsageBit::OutputAttachment,
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
kColorFormat);
|
||||||
kDepthStencilFormat);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
|
||||||
|
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
||||||
utils::ComboRenderPassDescriptor renderPassDescriptor({srcTexture.CreateDefaultView()},
|
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
||||||
depthStencilTexture.CreateDefaultView());
|
kDepthStencilFormat);
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Load;
|
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Clear;
|
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.clearStencil = 0;
|
utils::ComboRenderPassDescriptor renderPassDescriptor({srcTexture.CreateDefaultView()},
|
||||||
|
depthStencilTexture.CreateDefaultView());
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Load;
|
||||||
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
|
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Clear;
|
||||||
pass.SetPipeline(CreatePipelineForTest());
|
renderPassDescriptor.cDepthStencilAttachmentInfo.clearStencil = 0;
|
||||||
pass.Draw(6, 1, 0, 0);
|
|
||||||
pass.EndPass();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
dawn::CommandBuffer commandBuffer = encoder.Finish();
|
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
|
||||||
queue.Submit(1, &commandBuffer);
|
pass.SetPipeline(CreatePipelineForTest());
|
||||||
|
pass.Draw(6, 1, 0, 0);
|
||||||
// Expect the texture to be red because depth test passed.
|
pass.EndPass();
|
||||||
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
|
dawn::CommandBuffer commandBuffer = encoder.Finish();
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
queue.Submit(1, &commandBuffer);
|
||||||
}
|
|
||||||
|
// Expect the texture to be red because depth test passed.
|
||||||
// This tests the texture with stencil attachment and load op load will init depth stencil texture
|
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
|
||||||
// to 0s.
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
||||||
TEST_P(TextureZeroInitTest, StencilClear) {
|
}
|
||||||
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
|
||||||
1, 1,
|
// This tests the texture with stencil attachment and load op load will init depth stencil texture
|
||||||
dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::TransferDst |
|
// to 0s.
|
||||||
dawn::TextureUsageBit::OutputAttachment,
|
TEST_P(TextureZeroInitTest, RenderingLoadingStencil) {
|
||||||
kColorFormat);
|
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
1, 1,
|
||||||
|
dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::TransferDst |
|
||||||
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
dawn::TextureUsageBit::OutputAttachment,
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
kColorFormat);
|
||||||
kDepthStencilFormat);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
|
||||||
|
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
||||||
utils::ComboRenderPassDescriptor renderPassDescriptor({srcTexture.CreateDefaultView()},
|
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
||||||
depthStencilTexture.CreateDefaultView());
|
kDepthStencilFormat);
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
|
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.clearDepth = 0.0f;
|
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Load;
|
utils::ComboRenderPassDescriptor renderPassDescriptor({srcTexture.CreateDefaultView()},
|
||||||
|
depthStencilTexture.CreateDefaultView());
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
|
||||||
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
|
renderPassDescriptor.cDepthStencilAttachmentInfo.clearDepth = 0.0f;
|
||||||
pass.SetPipeline(CreatePipelineForTest());
|
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Load;
|
||||||
pass.Draw(6, 1, 0, 0);
|
|
||||||
pass.EndPass();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
dawn::CommandBuffer commandBuffer = encoder.Finish();
|
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
|
||||||
queue.Submit(1, &commandBuffer);
|
pass.SetPipeline(CreatePipelineForTest());
|
||||||
|
pass.Draw(6, 1, 0, 0);
|
||||||
// Expect the texture to be red because stencil test passed.
|
pass.EndPass();
|
||||||
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
|
dawn::CommandBuffer commandBuffer = encoder.Finish();
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
queue.Submit(1, &commandBuffer);
|
||||||
}
|
|
||||||
|
// Expect the texture to be red because stencil test passed.
|
||||||
// This tests the texture with depth stencil attachment and load op load will init depth stencil
|
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
|
||||||
// texture to 0s.
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
||||||
TEST_P(TextureZeroInitTest, DepthStencilClear) {
|
}
|
||||||
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
|
||||||
1, 1,
|
// This tests the texture with depth stencil attachment and load op load will init depth stencil
|
||||||
dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::TransferDst |
|
// texture to 0s.
|
||||||
dawn::TextureUsageBit::OutputAttachment,
|
TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) {
|
||||||
kColorFormat);
|
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
1, 1,
|
||||||
|
dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::TransferDst |
|
||||||
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
dawn::TextureUsageBit::OutputAttachment,
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
kColorFormat);
|
||||||
kDepthStencilFormat);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
|
||||||
|
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
||||||
utils::ComboRenderPassDescriptor renderPassDescriptor({srcTexture.CreateDefaultView()},
|
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
||||||
depthStencilTexture.CreateDefaultView());
|
kDepthStencilFormat);
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Load;
|
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
||||||
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Load;
|
|
||||||
|
utils::ComboRenderPassDescriptor renderPassDescriptor({srcTexture.CreateDefaultView()},
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
depthStencilTexture.CreateDefaultView());
|
||||||
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
|
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Load;
|
||||||
pass.SetPipeline(CreatePipelineForTest());
|
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Load;
|
||||||
pass.Draw(6, 1, 0, 0);
|
|
||||||
pass.EndPass();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
dawn::CommandBuffer commandBuffer = encoder.Finish();
|
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
|
||||||
queue.Submit(1, &commandBuffer);
|
pass.SetPipeline(CreatePipelineForTest());
|
||||||
|
pass.Draw(6, 1, 0, 0);
|
||||||
// Expect the texture to be red because both depth and stencil tests passed.
|
pass.EndPass();
|
||||||
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
|
dawn::CommandBuffer commandBuffer = encoder.Finish();
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
queue.Submit(1, &commandBuffer);
|
||||||
}
|
|
||||||
|
// Expect the texture to be red because both depth and stencil tests passed.
|
||||||
DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
|
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
|
||||||
ForceWorkarounds(D3D12Backend,
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
||||||
{"nonzero_clear_resources_on_creation_for_testing"}),
|
}
|
||||||
ForceWorkarounds(VulkanBackend,
|
|
||||||
{"nonzero_clear_resources_on_creation_for_testing"}));
|
DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
|
||||||
|
ForceWorkarounds(D3D12Backend,
|
||||||
|
{"nonzero_clear_resources_on_creation_for_testing"}),
|
||||||
|
ForceWorkarounds(VulkanBackend,
|
||||||
|
{"nonzero_clear_resources_on_creation_for_testing"}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user