use TransitionUsageImpl

This commit is contained in:
Kai Ninomiya 2017-08-30 16:15:36 -07:00 committed by Kai Ninomiya
parent 720a5d9366
commit 169809c458
7 changed files with 9 additions and 13 deletions

View File

@ -144,7 +144,7 @@ namespace backend {
return;
}
TransitionUsageImpl(currentUsage, usage);
currentUsage = usage;
UpdateUsageInternal(usage);
}
void TextureBase::FreezeUsage(nxt::TextureUsageBit usage) {
@ -154,7 +154,7 @@ namespace backend {
}
allowedUsage = usage;
TransitionUsageImpl(currentUsage, usage);
currentUsage = usage;
UpdateUsageInternal(usage);
frozen = true;
}

View File

@ -53,9 +53,9 @@ namespace backend {
void TransitionUsage(nxt::TextureUsageBit usage);
void FreezeUsage(nxt::TextureUsageBit usage);
private:
virtual void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) = 0;
private:
DeviceBase* device;
nxt::TextureDimension dimension;

View File

@ -279,11 +279,9 @@ namespace d3d12 {
Texture* texture = ToBackend(currentFramebuffer->GetTextureView(attachmentSlot)->GetTexture());
constexpr auto usage = nxt::TextureUsageBit::OutputAttachment;
// It's already validated that this texture is either frozen to the correct usage, or not frozen.
if (!texture->IsFrozen()) {
D3D12_RESOURCE_BARRIER barrier;
if (texture->GetResourceTransitionBarrier(texture->GetUsage(), usage, &barrier)) {
commandList->ResourceBarrier(1, &barrier);
}
texture->TransitionUsageImpl(texture->GetUsage(), usage);
texture->UpdateUsageInternal(usage);
}

View File

@ -36,13 +36,12 @@ namespace d3d12 {
ID3D12Resource* GetD3D12Resource();
bool GetResourceTransitionBarrier(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage, D3D12_RESOURCE_BARRIER* barrier);
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
private:
Device* device;
ComPtr<ID3D12Resource> resource = {};
ID3D12Resource* resourcePtr = nullptr;
// NXT API
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
};
class TextureView : public TextureViewBase {

View File

@ -32,9 +32,9 @@ namespace metal {
id<MTLTexture> GetMTLTexture();
private:
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
private:
id<MTLTexture> mtlTexture = nil;
};

View File

@ -169,7 +169,6 @@ namespace null {
Texture(TextureBuilder* builder);
~Texture();
private:
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
};

View File

@ -40,9 +40,9 @@ namespace opengl {
GLenum GetGLTarget() const;
TextureFormatInfo GetGLFormat() const;
private:
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
private:
GLuint handle;
GLenum target;
};