Implement 3D textures and views creation on D3D12 backend

This change also adds a very simple end2end test to verify that
we can create 3D textures and views. But we can't do anything
with them (like copy, sampling, rendering, etc) currently.

I will implement 3d textures and views creation on other backend
in one patch if the simple end2end test is OK.

Bug: dawn:547
Change-Id: I1662458de563cc4b47040a8bc3e94d7a8e0109e5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/39843
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He
2021-02-02 18:45:50 +00:00
committed by Commit Bot service account
parent dd988bca84
commit 04242a063e
2 changed files with 33 additions and 2 deletions

View File

@@ -45,6 +45,20 @@ namespace {
return device.CreateTexture(&descriptor);
}
wgpu::Texture Create3DTexture(wgpu::Device device,
wgpu::Extent3D size,
uint32_t mipLevelCount,
wgpu::TextureUsage usage) {
wgpu::TextureDescriptor descriptor;
descriptor.dimension = wgpu::TextureDimension::e3D;
descriptor.size = size;
descriptor.sampleCount = 1;
descriptor.format = kDefaultFormat;
descriptor.mipLevelCount = mipLevelCount;
descriptor.usage = usage;
return device.CreateTexture(&descriptor);
}
wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) {
return utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
@@ -678,3 +692,13 @@ DAWN_INSTANTIATE_TEST(TextureViewTest,
OpenGLBackend(),
OpenGLESBackend(),
VulkanBackend());
class TextureView3DTest : public DawnTest {};
// Test that 3D textures and 3D texture views can be created successfully
TEST_P(TextureView3DTest, BasicTest) {
wgpu::Texture texture = Create3DTexture(device, {4, 4, 4}, 3, wgpu::TextureUsage::Sampled);
wgpu::TextureView view = texture.CreateView();
}
DAWN_INSTANTIATE_TEST(TextureView3DTest, D3D12Backend());