Remove TextureViewBuilder and add CreateDefaultTextureView entry point

This patch is the first one to descriptorze texture view. In this
patch, we completely remove TextureViewBuilder and add the entry
point CreateDefaultTextureView for creating a texture view on a
non-array 2D texture using the same type and format.

Texture view descriptors and 2D array texture views will be supported
in the next patch.

BUG=dawn:1, dawn:16

Change-Id: Ibd2a0bcf02cbb567a98d2faaaaa897eff2c062e5
Reviewed-on: https://dawn-review.googlesource.com/1440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2018-09-18 00:31:57 +00:00 committed by Commit Bot service account
parent 03e1813fd2
commit 3d670506e3
33 changed files with 46 additions and 82 deletions

View File

@ -985,8 +985,8 @@
"category": "object",
"methods": [
{
"name": "create texture view builder",
"returns": "texture view builder"
"name": "create default texture view",
"returns": "texture view"
}
]
},
@ -1038,15 +1038,6 @@
"texture view": {
"category": "object"
},
"texture view builder": {
"category": "object",
"methods": [
{
"name": "get result",
"returns": "texture view"
}
]
},
"vertex format": {
"category": "enum",
"values": [

View File

@ -72,9 +72,7 @@ void frame() {
dawnTexture backbuffer = dawnSwapChainGetNextTexture(swapchain);
dawnTextureView backbufferView;
{
dawnTextureViewBuilder builder = dawnTextureCreateTextureViewBuilder(backbuffer);
backbufferView = dawnTextureViewBuilderGetResult(builder);
dawnTextureViewBuilderRelease(builder);
backbufferView = dawnTextureCreateDefaultTextureView(backbuffer);
}
dawnRenderPassDescriptor renderpassInfo;
{

View File

@ -131,7 +131,7 @@ void init() {
.SetInputState(inputState)
.GetResult();
dawn::TextureView view = texture.CreateTextureViewBuilder().GetResult();
dawn::TextureView view = texture.CreateDefaultTextureView();
bindGroup = device.CreateBindGroupBuilder()
.SetLayout(bgl)

View File

@ -146,8 +146,7 @@ dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
descriptor.mipLevel = 1;
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
auto depthStencilTexture = device.CreateTexture(&descriptor);
return depthStencilTexture.CreateTextureViewBuilder()
.GetResult();
return depthStencilTexture.CreateDefaultTextureView();
}
void GetNextRenderPassDescriptor(const dawn::Device& device,
@ -156,7 +155,7 @@ void GetNextRenderPassDescriptor(const dawn::Device& device,
dawn::Texture* backbuffer,
dawn::RenderPassDescriptor* info) {
*backbuffer = swapchain.GetNextTexture();
auto backbufferView = backbuffer->CreateTextureViewBuilder().GetResult();
auto backbufferView = backbuffer->CreateDefaultTextureView();
*info = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, backbufferView, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthStencilView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)

View File

@ -438,7 +438,7 @@ namespace {
.GetResult();
queue.Submit(1, &cmdbuf);
textures[iTextureID] = oTexture.CreateTextureViewBuilder().GetResult();
textures[iTextureID] = oTexture.CreateDefaultTextureView();
}
}

View File

@ -56,7 +56,7 @@ namespace dawn_native {
RenderPassDescriptorBuilder* builder) = 0;
virtual RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) = 0;
virtual SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) = 0;
virtual TextureViewBase* CreateTextureView(TextureViewBuilder* builder) = 0;
virtual TextureViewBase* CreateDefaultTextureView(TextureBase* texture) = 0;
virtual void TickImpl() = 0;

View File

@ -126,13 +126,13 @@ namespace dawn_native {
return mUsage;
}
TextureViewBuilder* TextureBase::CreateTextureViewBuilder() {
return new TextureViewBuilder(mDevice, this);
TextureViewBase* TextureBase::CreateDefaultTextureView() {
return mDevice->CreateDefaultTextureView(this);
}
// TextureViewBase
TextureViewBase::TextureViewBase(TextureViewBuilder* builder) : mTexture(builder->mTexture) {
TextureViewBase::TextureViewBase(TextureBase* texture) : mTexture(texture) {
}
const TextureBase* TextureViewBase::GetTexture() const {
@ -143,14 +143,4 @@ namespace dawn_native {
return mTexture.Get();
}
// TextureViewBuilder
TextureViewBuilder::TextureViewBuilder(DeviceBase* device, TextureBase* texture)
: Builder(device), mTexture(texture) {
}
TextureViewBase* TextureViewBuilder::GetResultImpl() {
return mDevice->CreateTextureView(this);
}
} // namespace dawn_native

View File

@ -53,7 +53,7 @@ namespace dawn_native {
DeviceBase* GetDevice() const;
// Dawn API
TextureViewBuilder* CreateTextureViewBuilder();
TextureViewBase* CreateDefaultTextureView();
private:
DeviceBase* mDevice;
@ -68,7 +68,7 @@ namespace dawn_native {
class TextureViewBase : public RefCounted {
public:
TextureViewBase(TextureViewBuilder* builder);
TextureViewBase(TextureBase* texture);
const TextureBase* GetTexture() const;
TextureBase* GetTexture();
@ -77,18 +77,6 @@ namespace dawn_native {
Ref<TextureBase> mTexture;
};
class TextureViewBuilder : public Builder<TextureViewBase> {
public:
TextureViewBuilder(DeviceBase* device, TextureBase* texture);
private:
friend class TextureViewBase;
TextureViewBase* GetResultImpl() override;
Ref<TextureBase> mTexture;
};
} // namespace dawn_native
#endif // DAWNNATIVE_TEXTURE_H_

View File

@ -325,8 +325,8 @@ namespace dawn_native { namespace d3d12 {
ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
return new Texture(this, descriptor);
}
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
return new TextureView(builder);
TextureViewBase* Device::CreateDefaultTextureView(TextureBase* texture) {
return new TextureView(texture);
}
}} // namespace dawn_native::d3d12

View File

@ -51,7 +51,7 @@ namespace dawn_native { namespace d3d12 {
RenderPassDescriptorBuilder* builder) override;
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
TextureViewBase* CreateDefaultTextureView(TextureBase* texture) override;
void TickImpl() override;

View File

@ -184,7 +184,7 @@ namespace dawn_native { namespace d3d12 {
mLastUsage = usage;
}
TextureView::TextureView(TextureViewBuilder* builder) : TextureViewBase(builder) {
TextureView::TextureView(TextureBase* texture) : TextureViewBase(texture) {
mSrvDesc.Format = D3D12TextureFormat(GetTexture()->GetFormat());
mSrvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
switch (GetTexture()->GetDimension()) {

View File

@ -47,7 +47,7 @@ namespace dawn_native { namespace d3d12 {
class TextureView : public TextureViewBase {
public:
TextureView(TextureViewBuilder* builder);
TextureView(TextureBase* builder);
const D3D12_SHADER_RESOURCE_VIEW_DESC& GetSRVDescriptor() const;
D3D12_RENDER_TARGET_VIEW_DESC GetRTVDescriptor();

View File

@ -47,7 +47,7 @@ namespace dawn_native { namespace metal {
RenderPassDescriptorBuilder* builder) override;
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
TextureViewBase* CreateDefaultTextureView(TextureBase* texture) override;
void TickImpl() override;

View File

@ -131,8 +131,8 @@ namespace dawn_native { namespace metal {
ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
return new Texture(this, descriptor);
}
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
return new TextureView(builder);
TextureViewBase* Device::CreateDefaultTextureView(TextureBase* texture) {
return new TextureView(texture);
}
void Device::TickImpl() {

View File

@ -39,7 +39,7 @@ namespace dawn_native { namespace metal {
class TextureView : public TextureViewBase {
public:
TextureView(TextureViewBuilder* builder);
TextureView(TextureBase* texture);
};
}} // namespace dawn_native::metal

View File

@ -98,7 +98,7 @@ namespace dawn_native { namespace metal {
return mMtlTexture;
}
TextureView::TextureView(TextureViewBuilder* builder) : TextureViewBase(builder) {
TextureView::TextureView(TextureBase* texture) : TextureViewBase(texture) {
}
}} // namespace dawn_native::metal

View File

@ -94,8 +94,8 @@ namespace dawn_native { namespace null {
ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
return new Texture(this, descriptor);
}
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
return new TextureView(builder);
TextureViewBase* Device::CreateDefaultTextureView(TextureBase* texture) {
return new TextureView(texture);
}
void Device::TickImpl() {

View File

@ -105,7 +105,7 @@ namespace dawn_native { namespace null {
RenderPassDescriptorBuilder* builder) override;
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
TextureViewBase* CreateDefaultTextureView(TextureBase* texture) override;
void TickImpl() override;

View File

@ -102,8 +102,8 @@ namespace dawn_native { namespace opengl {
ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
return new Texture(this, descriptor);
}
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
return new TextureView(builder);
TextureViewBase* Device::CreateDefaultTextureView(TextureBase* texture) {
return new TextureView(texture);
}
void Device::TickImpl() {

View File

@ -42,7 +42,7 @@ namespace dawn_native { namespace opengl {
RenderPassDescriptorBuilder* builder) override;
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
TextureViewBase* CreateDefaultTextureView(TextureBase* texture) override;
void TickImpl() override;

View File

@ -129,7 +129,7 @@ namespace dawn_native { namespace opengl {
// TextureView
TextureView::TextureView(TextureViewBuilder* builder) : TextureViewBase(builder) {
TextureView::TextureView(TextureBase* texture) : TextureViewBase(texture) {
}
}} // namespace dawn_native::opengl

View File

@ -46,7 +46,7 @@ namespace dawn_native { namespace opengl {
class TextureView : public TextureViewBase {
public:
TextureView(TextureViewBuilder* builder);
TextureView(TextureBase* texture);
};
}} // namespace dawn_native::opengl

View File

@ -266,8 +266,8 @@ namespace dawn_native { namespace vulkan {
ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
return new Texture(this, descriptor);
}
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
return new TextureView(builder);
TextureViewBase* Device::CreateDefaultTextureView(TextureBase* texture) {
return new TextureView(texture);
}
void Device::TickImpl() {

View File

@ -74,7 +74,7 @@ namespace dawn_native { namespace vulkan {
RenderPassDescriptorBuilder* builder) override;
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
TextureViewBase* CreateDefaultTextureView(TextureBase* texture) override;
void TickImpl() override;

View File

@ -342,8 +342,8 @@ namespace dawn_native { namespace vulkan {
mLastUsage = usage;
}
TextureView::TextureView(TextureViewBuilder* builder) : TextureViewBase(builder) {
Device* device = ToBackend(builder->GetDevice());
TextureView::TextureView(TextureBase* texture) : TextureViewBase(texture) {
Device* device = ToBackend(texture->GetDevice());
VkImageViewCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;

View File

@ -50,7 +50,7 @@ namespace dawn_native { namespace vulkan {
class TextureView : public TextureViewBase {
public:
TextureView(TextureViewBuilder* builder);
TextureView(TextureBase* texture);
~TextureView();
VkImageView GetHandle() const;

View File

@ -702,7 +702,7 @@ TEST_P(BlendStateTest, IndependentBlendState) {
for (uint32_t i = 0; i < 4; ++i) {
renderTargets[i] = device.CreateTexture(&descriptor);
renderTargetViews[i] = renderTargets[i].CreateTextureViewBuilder().GetResult();
renderTargetViews[i] = renderTargets[i].CreateDefaultTextureView();
}
dawn::RenderPassDescriptor renderpass = device.CreateRenderPassDescriptorBuilder()

View File

@ -35,7 +35,7 @@ class DepthStencilStateTest : public DawnTest {
renderTargetDescriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
renderTarget = device.CreateTexture(&renderTargetDescriptor);
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
renderTargetView = renderTarget.CreateDefaultTextureView();
dawn::TextureDescriptor depthDescriptor;
depthDescriptor.dimension = dawn::TextureDimension::e2D;
@ -48,7 +48,7 @@ class DepthStencilStateTest : public DawnTest {
depthDescriptor.usage = dawn::TextureUsageBit::OutputAttachment;
depthTexture = device.CreateTexture(&depthDescriptor);
depthTextureView = depthTexture.CreateTextureViewBuilder().GetResult();
depthTextureView = depthTexture.CreateDefaultTextureView();
renderpass = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, dawn::LoadOp::Clear)

View File

@ -66,7 +66,7 @@ class RenderPassLoadOpTests : public DawnTest {
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
renderTarget = device.CreateTexture(&descriptor);
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
renderTargetView = renderTarget.CreateDefaultTextureView();
RGBA8 zero(0, 0, 0, 0);
std::fill(expectZero.begin(), expectZero.end(), zero);

View File

@ -105,7 +105,7 @@ protected:
.GetResult();
queue.Submit(1, &copy);
mTextureView = texture.CreateTextureViewBuilder().GetResult();
mTextureView = texture.CreateDefaultTextureView();
}
void TestAddressModes(AddressModeTestCase u, AddressModeTestCase v, AddressModeTestCase w) {

View File

@ -33,8 +33,7 @@ dawn::TextureView Create2DAttachment(dawn::Device& device, uint32_t width, uint3
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
dawn::Texture attachment = device.CreateTexture(&descriptor);
return attachment.CreateTextureViewBuilder()
.GetResult();
return attachment.CreateDefaultTextureView();
}
// A render pass with no attachments isn't valid

View File

@ -85,8 +85,7 @@ dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
auto colorBuffer = device.CreateTexture(&descriptor);
auto colorView = colorBuffer.CreateTextureViewBuilder()
.GetResult();
auto colorView = colorBuffer.CreateDefaultTextureView();
return device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
@ -139,7 +138,7 @@ ValidationTest::DummyRenderPass ValidationTest::CreateDummyRenderPass() {
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
dummy.attachment = device.CreateTexture(&descriptor);
dawn::TextureView view = AssertWillBeSuccess(dummy.attachment.CreateTextureViewBuilder()).GetResult();
dawn::TextureView view = dummy.attachment.CreateDefaultTextureView();
dummy.renderPass = AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, view, dawn::LoadOp::Clear)

View File

@ -145,7 +145,7 @@ namespace utils {
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
result.color = device.CreateTexture(&descriptor);
dawn::TextureView colorView = result.color.CreateTextureViewBuilder().GetResult();
dawn::TextureView colorView = result.color.CreateDefaultTextureView();
result.renderPassInfo = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
.GetResult();