use TransitionUsageImpl
This commit is contained in:
parent
720a5d9366
commit
169809c458
|
@ -144,7 +144,7 @@ namespace backend {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TransitionUsageImpl(currentUsage, usage);
|
TransitionUsageImpl(currentUsage, usage);
|
||||||
currentUsage = usage;
|
UpdateUsageInternal(usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureBase::FreezeUsage(nxt::TextureUsageBit usage) {
|
void TextureBase::FreezeUsage(nxt::TextureUsageBit usage) {
|
||||||
|
@ -154,7 +154,7 @@ namespace backend {
|
||||||
}
|
}
|
||||||
allowedUsage = usage;
|
allowedUsage = usage;
|
||||||
TransitionUsageImpl(currentUsage, usage);
|
TransitionUsageImpl(currentUsage, usage);
|
||||||
currentUsage = usage;
|
UpdateUsageInternal(usage);
|
||||||
frozen = true;
|
frozen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,9 @@ namespace backend {
|
||||||
void TransitionUsage(nxt::TextureUsageBit usage);
|
void TransitionUsage(nxt::TextureUsageBit usage);
|
||||||
void FreezeUsage(nxt::TextureUsageBit usage);
|
void FreezeUsage(nxt::TextureUsageBit usage);
|
||||||
|
|
||||||
private:
|
|
||||||
virtual void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) = 0;
|
virtual void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
DeviceBase* device;
|
DeviceBase* device;
|
||||||
|
|
||||||
nxt::TextureDimension dimension;
|
nxt::TextureDimension dimension;
|
||||||
|
|
|
@ -279,11 +279,9 @@ namespace d3d12 {
|
||||||
|
|
||||||
Texture* texture = ToBackend(currentFramebuffer->GetTextureView(attachmentSlot)->GetTexture());
|
Texture* texture = ToBackend(currentFramebuffer->GetTextureView(attachmentSlot)->GetTexture());
|
||||||
constexpr auto usage = nxt::TextureUsageBit::OutputAttachment;
|
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()) {
|
if (!texture->IsFrozen()) {
|
||||||
D3D12_RESOURCE_BARRIER barrier;
|
texture->TransitionUsageImpl(texture->GetUsage(), usage);
|
||||||
if (texture->GetResourceTransitionBarrier(texture->GetUsage(), usage, &barrier)) {
|
|
||||||
commandList->ResourceBarrier(1, &barrier);
|
|
||||||
}
|
|
||||||
texture->UpdateUsageInternal(usage);
|
texture->UpdateUsageInternal(usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,12 @@ namespace d3d12 {
|
||||||
ID3D12Resource* GetD3D12Resource();
|
ID3D12Resource* GetD3D12Resource();
|
||||||
bool GetResourceTransitionBarrier(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage, D3D12_RESOURCE_BARRIER* barrier);
|
bool GetResourceTransitionBarrier(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage, D3D12_RESOURCE_BARRIER* barrier);
|
||||||
|
|
||||||
|
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Device* device;
|
Device* device;
|
||||||
ComPtr<ID3D12Resource> resource = {};
|
ComPtr<ID3D12Resource> resource = {};
|
||||||
ID3D12Resource* resourcePtr = nullptr;
|
ID3D12Resource* resourcePtr = nullptr;
|
||||||
|
|
||||||
// NXT API
|
|
||||||
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureView : public TextureViewBase {
|
class TextureView : public TextureViewBase {
|
||||||
|
|
|
@ -32,9 +32,9 @@ namespace metal {
|
||||||
|
|
||||||
id<MTLTexture> GetMTLTexture();
|
id<MTLTexture> GetMTLTexture();
|
||||||
|
|
||||||
private:
|
|
||||||
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
||||||
|
|
||||||
|
private:
|
||||||
id<MTLTexture> mtlTexture = nil;
|
id<MTLTexture> mtlTexture = nil;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,6 @@ namespace null {
|
||||||
Texture(TextureBuilder* builder);
|
Texture(TextureBuilder* builder);
|
||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
private:
|
|
||||||
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@ namespace opengl {
|
||||||
GLenum GetGLTarget() const;
|
GLenum GetGLTarget() const;
|
||||||
TextureFormatInfo GetGLFormat() const;
|
TextureFormatInfo GetGLFormat() const;
|
||||||
|
|
||||||
private:
|
|
||||||
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
|
||||||
|
|
||||||
|
private:
|
||||||
GLuint handle;
|
GLuint handle;
|
||||||
GLenum target;
|
GLenum target;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue