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:
parent
03e1813fd2
commit
3d670506e3
13
dawn.json
13
dawn.json
|
@ -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": [
|
||||
|
|
|
@ -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;
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -438,7 +438,7 @@ namespace {
|
|||
.GetResult();
|
||||
queue.Submit(1, &cmdbuf);
|
||||
|
||||
textures[iTextureID] = oTexture.CreateTextureViewBuilder().GetResult();
|
||||
textures[iTextureID] = oTexture.CreateDefaultTextureView();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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_
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
class TextureView : public TextureViewBase {
|
||||
public:
|
||||
TextureView(TextureViewBuilder* builder);
|
||||
TextureView(TextureBase* texture);
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::metal
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
class TextureView : public TextureViewBase {
|
||||
public:
|
||||
TextureView(TextureViewBuilder* builder);
|
||||
TextureView(TextureBase* texture);
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
class TextureView : public TextureViewBase {
|
||||
public:
|
||||
TextureView(TextureViewBuilder* builder);
|
||||
TextureView(TextureBase* texture);
|
||||
~TextureView();
|
||||
|
||||
VkImageView GetHandle() const;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -105,7 +105,7 @@ protected:
|
|||
.GetResult();
|
||||
|
||||
queue.Submit(1, ©);
|
||||
mTextureView = texture.CreateTextureViewBuilder().GetResult();
|
||||
mTextureView = texture.CreateDefaultTextureView();
|
||||
}
|
||||
|
||||
void TestAddressModes(AddressModeTestCase u, AddressModeTestCase v, AddressModeTestCase w) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue