mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 04:24:11 +01:00
[d3d11] Implement DiscardView and DiscardResource for images
This commit is contained in:
parent
0d9e714d3e
commit
0b4f1b6d6f
@ -72,13 +72,31 @@ namespace dxvk {
|
||||
|
||||
if (resType == D3D11_RESOURCE_DIMENSION_BUFFER)
|
||||
DiscardBuffer(static_cast<D3D11Buffer*>(pResource));
|
||||
else if (resType != D3D11_RESOURCE_DIMENSION_UNKNOWN)
|
||||
DiscardTexture(GetCommonTexture(pResource));
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11DeviceContext::DiscardView(ID3D11View* pResourceView) {
|
||||
// Ignore. We don't do Discard for images or image
|
||||
// subresources, and for buffers we could only really
|
||||
// do this if the view covers the entire buffer.
|
||||
// ID3D11View has no methods to query the exact type of
|
||||
// the view, so we'll have to check each possible class
|
||||
auto dsv = dynamic_cast<D3D11DepthStencilView*>(pResourceView);
|
||||
auto rtv = dynamic_cast<D3D11RenderTargetView*>(pResourceView);
|
||||
auto uav = dynamic_cast<D3D11UnorderedAccessView*>(pResourceView);
|
||||
|
||||
Rc<DxvkImageView> view;
|
||||
if (dsv) view = dsv->GetImageView();
|
||||
if (rtv) view = rtv->GetImageView();
|
||||
if (uav) view = uav->GetImageView();
|
||||
|
||||
if (view != nullptr) {
|
||||
EmitCs([cView = std::move(view)]
|
||||
(DxvkContext* ctx) {
|
||||
ctx->discardImage(
|
||||
cView->image(),
|
||||
cView->subresources());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2907,6 +2925,18 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void D3D11DeviceContext::DiscardTexture(
|
||||
D3D11CommonTexture* pTexture) {
|
||||
EmitCs([cImage = pTexture->GetImage()] (DxvkContext* ctx) {
|
||||
VkImageSubresourceRange subresources = {
|
||||
cImage->formatInfo()->aspectMask,
|
||||
0, cImage->info().mipLevels,
|
||||
0, cImage->info().numLayers };
|
||||
ctx->discardImage(cImage, subresources);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void D3D11DeviceContext::SetConstantBuffers(
|
||||
DxbcProgramType ShaderStage,
|
||||
D3D11ConstantBufferBindings& Bindings,
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "d3d11_annotation.h"
|
||||
#include "d3d11_context_state.h"
|
||||
#include "d3d11_device_child.h"
|
||||
#include "d3d11_texture.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
@ -707,6 +708,9 @@ namespace dxvk {
|
||||
void DiscardBuffer(
|
||||
D3D11Buffer* pBuffer);
|
||||
|
||||
void DiscardTexture(
|
||||
D3D11CommonTexture* pTexture);
|
||||
|
||||
void SetConstantBuffers(
|
||||
DxbcProgramType ShaderStage,
|
||||
D3D11ConstantBufferBindings& Bindings,
|
||||
|
Loading…
Reference in New Issue
Block a user